Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Read n lines from the top of a text file

by robin (Chaplain)
on Dec 23, 2001 at 18:38 UTC ( [id://134065]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://134065]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (1)
As of 2024-04-19 00:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found