Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Re: The problem with one-liners...

by petral (Curate)
on Feb 03, 2003 at 23:40 UTC ( #232413=note: print w/ replies, xml ) Need Help??

in reply to Re: The problem with one-liners...
in thread The problem with one-liners...

Oh well, a little fiddling since it's such fun stuff:

# Last line of a file perl -pe '$*=$_}{$_=$*' file
->   perl -pe '$\=$_}{' file

Which leads me to a head-tail (useful eg, for finding out the range of a log file).
perl -pe '$*||=$_; $\=$_}{$_=$*' file
and (not stopping while he's ahead) . . .
# Exit after first match perl -ne 'print; last if /foo/' file
->   perl -pe '/foo/...last' file


Comment on Re: Re: The problem with one-liners...
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2015-12-01 03:35 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (792 votes), past polls