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

Re: How to print a newline in oneliners ...

by Anonymous Monk
on Apr 22, 2014 at 16:35 UTC ( [id://1083196]=note: print w/replies, xml ) Need Help??


in reply to How to print a newline in oneliners ...

I use the -l switch without a value all the time:

for i in {0..9}; do echo $i; done | perl -nle '$_++; print'

It's the equivalent of $\ = $/ and a chomp on the input.

Replies are listed 'Best First'.
Re^2: How to print a newline in oneliners ...
by GotToBTru (Prior) on Apr 22, 2014 at 17:43 UTC
    for in in {0..9}; do echo $i; done | perl -nle 'print ++$_'

      Well if you wanna play that game... ;-)

      for i in {0..9}; do echo $i; done | perl -ple '$_++'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-29 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found