Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: REGEX Non-Destructive Flag

by toolic (Bishop)
on Jan 10, 2012 at 17:42 UTC ( [id://947202]=note: print w/replies, xml ) Need Help??


in reply to REGEX Non-Destructive Flag

It is not implemented in 5.8.8. It was added in 5.14: see perl514delta. I don't think you can get it without upgrading all of perl.

Replies are listed 'Best First'.
Re^2: REGEX Non-Destructive Flag
by mmartin (Monk) on Jan 10, 2012 at 17:54 UTC
    Hey toolic, thanks for the reply.

    Ok I was afraid of that... Thanks

    Is there an easier way (less lines) that I could use with my version like my previous example (i.e. $str = $str2 =~ s/pattern/replace/r; ).

    The only way I can think to do this without changing the original string is:
    my $str1 = "How-Are-You-Doing" my $str2 = $str1 $str2 =~ s/-/ /; print $str2; ____OUTPUT____ Hello How Are You Doing


    Thanks,
    Matt


       perl -ne '(my $foo = $_) =~ s/-/ /g;'

      The assignment returns an lvalue which then gets the substitution run on it. Basically the same as yours, just in one statement.

      --MidLifeXis

Re^2: REGEX Non-Destructive Flag
by i5513 (Pilgrim) on Jan 10, 2012 at 19:42 UTC

    mm, seems like "/r" is not in perlre, although at start says it is "Perl 5 version 14.1 documentation"

    Is it deliberated ? or it is a simple bug in the doc which should be reported?

    Thanks!

    UPDATE: Thanks to toolic, it is true

    I was confused by perldelta because "/r" was in "Regular Expressions" section there

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-03-19 04:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found