in reply to Re: Read n lines from the top of a text file
in thread Read n lines from the top of a text file

This (reading 10 lines from the top of a text file) was the first hole in the recent fwp golf competition. Here's a summary of the solutions.

The cleverest answer was by Piers Cawley:

#!/usr/bin/perl -p 11..&
Bonus points if you can figure out how it works :-)

Replies are listed 'Best First'.
Re: Re: Re: Read n lines from the top of a text file
by tachyon (Chancellor) on Dec 23, 2001 at 19:35 UTC

    Hmm that is really obscure.

    C:\>perl -pe "11..&" test.pl 1 2 3 4 5 6 7 8 9 10 Undefined subroutine &main::; called, <> line 11. C:\>

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print