Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: One liner is returning unexpected "1" on the output and I do not understand the mechanism at play.

by Anonymous Monk
on Oct 17, 2020 at 21:39 UTC ( #11122966=note: print w/replies, xml ) Need Help??


in reply to Re^2: One liner is returning unexpected "1" on the output and I do not understand the mechanism at play.
in thread One liner is returning unexpected "1" on the output and I do not understand the mechanism at play.

...or use s///r

not what OP wants

  • Comment on Re^3: One liner is returning unexpected "1" on the output and I do not understand the mechanism at play.

Replies are listed 'Best First'.
Re^4: One liner is returning unexpected "1" on the output and I do not understand the mechanism at play.
by ikegami (Pope) on Oct 17, 2020 at 22:00 UTC

    Yes it is. They asked to "print line with no leading space" instead of "1".

    This can be achieved by replacing

    print s/^\s+//, ...; # This is printing 1
    with
    print s/^\s+//r, ...;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2020-12-05 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (63 votes). Check out past polls.

    Notices?