in reply to Re: 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.

Run the substitution before printing the result.

...or use s///r

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

Replies are listed 'Best First'.
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
    ...or use s///r

    not what OP wants

      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, ...;