Re: unhead (FWP)
Ian Phillipps <[email protected]>
| Newsgroups | gmane.comp.lang.perl.fun |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 27 Sep 2004 at 11:42:10 +0200, Tobias Gödderz wrote:
> On Mon, 2004-09-27 at 08:44, Gaal Yahas wrote:
> > All the other solutions are so horrendeously inefficient, performing a
> > branch every line. Tsk, tsk.
> > perl -ne 'BEGIN { $p = sub { $p = sub { print } if $. == 4 } } $p->()'
>
> Probably it will take longer to parse yours than the others to run. ;-)
>
> perl -ne 'print if $. - 4 > 0'
How about:
perl -pe 'BEGIN{<> for 1..4}'
Or - and here's the real fun - it changes the meaning of "..":
perl -pe 'BEGIN{<> if 1..4}'
In practice, I'd just use "head +4". Use your head. That's what my
granny always told me.
Ian
[I'm away from my emai for a week now...]