Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by sfink (Deacon)
on Jan 29, 2004 at 17:50 UTC ( #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
Node Status?
node history
Node Type: note [id://324988]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2014-10-01 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (38 votes), past polls