Re: unhead
On Sat, 25 Sep 2004 at 19:09:31 -0700, Randal L. Schwartz wrote: Keith == Keith C Ivey [EMAIL PROTECTED] writes: Well, it also presumes that ! returns literally 0 and 1. I've never seen a promise of that in any docs. I think Perl6 should return 42 for true, just to keep people from making that presumption. There's an implicit promise, which used to be more clearly stated, in that the '!' operator is inherited from 'C'. In that language, the behaviour is indeed specified. From the perl manual, version 1: Since perl expressions work almost exactly like C expressions, only the differences will be mentioned here And, yes, I know that it returns '' for false. Not much fun, sorry. But I can't out-golf Eugene... Ian
Re: unhead
Randal L. Schwartz [EMAIL PROTECTED] wrote: perl -ne 'print unless 1..5' perl -pe '$_ x=!(1..5)' -- Keith C. Ivey [EMAIL PROTECTED] Washington, DC
Re: unhead
Keith == Keith C Ivey [EMAIL PROTECTED] writes: Keith perl -pe '$_ x=!(1..5)' FWP. Not Golf. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Re: unhead
Randal L. Schwartz [EMAIL PROTECTED] wrote: Keith perl -pe '$_ x=!(1..5)' FWP. Not Golf. :) Well, I'm sure there's something better than that for golf (Ton probably has a 3-byte solution), but I think x= with a boolean righthand side *is* fun, and it's even handy for one-liners occasionally once you've gotten used to it. -- Keith C. Ivey [EMAIL PROTECTED] Washington, DC
unhead
You're probably all familiar with the commands head and tail, which let you extract the first or the last N lines of input or a file... Imagine you want to print a file, but without the first N lines... For N=1, one possibility would be: print if $. - 1; For any N, maybe this: print if ($N+1)..0; Any thoughts? Any other ideas? What would be the best way to do this? Regards, jac -- José Alves de Castro [EMAIL PROTECTED] http://natura.di.uminho.pt/~jac
Re: unhead
Here's a little oneliner to skip the first 5 lines of the file 'foo': perl -i5 -e '@_=STDIN;[EMAIL PROTECTED]' foo On Sep 24, 2004, at 7:17 AM, Jose Alves de Castro wrote: You're probably all familiar with the commands head and tail, which let you extract the first or the last N lines of input or a file... Imagine you want to print a file, but without the first N lines... For N=1, one possibility would be: print if $. - 1; For any N, maybe this: print if ($N+1)..0; Any thoughts? Any other ideas? What would be the best way to do this? Regards, jac -- José Alves de Castro [EMAIL PROTECTED] http://natura.di.uminho.pt/~jac
Re: unhead
On Fri, Sep 24, 2004 at 03:17:56PM +0100, Jose Alves de Castro wrote: print if ($N+1)..0; Implicit comparison to $. only happens for constants, so that should be ($. $N) .. 0
Re: unhead
I think we'd like to avoid solutions that involve loading entire file into an array, agreed? Here's how I'd do it: sed -n '5,$p' -- John Douglas Porter Josh Goldberg [EMAIL PROTECTED] wrote: Here's a little oneliner to skip the first 5 lines of the file 'foo': perl -i5 -e '@_=STDIN;[EMAIL PROTECTED]' foo On Sep 24, 2004, at 7:17 AM, Jose Alves de Castro wrote: You're probably all familiar with the commands head and tail, which let you extract the first or the last N lines of input or a file... Imagine you want to print a file, but without the first N lines... For N=1, one possibility would be: print if $. - 1; For any N, maybe this: print if ($N+1)..0; Any thoughts? Any other ideas? What would be the best way to do this? Regards, jac -- José Alves de Castro [EMAIL PROTECTED] http://natura.di.uminho.pt/~jac ___ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com