Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Uncommon* but Useful Perl Command Line Options for One-liners

by sfink (Deacon)
on Jan 29, 2004 at 17:50 UTC ( [id://324988]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl -l -n -e 'BEGIN{$sum=0;} $sum=$sum+ $1 if /(\d+)/;print $1; END {
    +print "Total: ",$sum}'
    
  2. or download this
    echo -e "a\nb\nc" | perl -lne 'next if /b/; print'
    a
    c
    echo -e "a\nb\nc" | perl -lne 'last if /b/; print'
    a
    
  3. or download this
    perl -lne 'print $s += $1 if /(\d+)/'
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-03-19 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found