Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: strange usage of s///

by brx (Pilgrim)
on Sep 03, 2013 at 21:01 UTC ( #1052179=note: print w/replies, xml ) Need Help??

in reply to strange usage of s/// [solved: Perl 5.14 and 5.16 bug]

B::Deparse seems to understand and to see difference between variants:

1) Original:

perl -MO=Deparse -e '$_="abcdef"; s/@{[s".."."gr]}\K$"//; print' $_ = 'abcdef'; s[@{[s/.././rg];}\K][$"]; print $_; -e syntax OK

Do the rigth thing, but why?!

2) Litteral space char (not $"):

perl -MO=Deparse -e '$_="abcdef"; s/@{[s".."."gr]}\K //; print' $_ = 'abcdef'; s[@{[s/.././rg];}][\\K ]; print $_; -e syntax OK

Strange, isn't it? :). I'm confused...

English is not my mother tongue.
Les tongues de ma mère sont "made in France".

Replies are listed 'Best First'.
Re^2: strange usage of s///
by smls (Friar) on Sep 03, 2013 at 22:25 UTC
    Perl v5.18.1 handles them as one would expect:
    perl -MO=Deparse -e '$_="abcdef"; s/@{[s".."."gr]}\K$"//; print' $_ = 'abcdef'; s[@{[s/.././gr];}\K$"][]; print $_; -e syntax OK
    perl -MO=Deparse -e '$_="abcdef"; s/@{[s".."."gr]}\K //; print' $_ = 'abcdef'; s[@{[s/.././gr];}\K ][]; print $_; -e syntax OK

    PS: With Perl v5.14.2 I get the same result as you.

    (Testing environment was 64bit Linux in both cases.)

    So yeah, strange indeed...

      Thank you very much, smls. Original post updated.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1052179]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2018-04-22 07:07 GMT
Find Nodes?
    Voting Booth?