Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^2: Perl oddities (s/// doesn't DWIM in map)

by Joost (Canon)
on Mar 01, 2005 at 14:06 UTC ( #435435=note: print w/ replies, xml ) Need Help??

in reply to Re: Perl oddities (s/// doesn't DWIM in map)
in thread Perl oddities

Good point. More generic: Having no built-in s/// that returns a modified copy is annoying.

Comment on Re^2: Perl oddities (s/// doesn't DWIM in map)
Replies are listed 'Best First'.
Re^3: Perl oddities (s/// doesn't DWIM in map)
by heptadecagram (Novice) on Mar 01, 2005 at 15:40 UTC

    True. I'd like to see a switch:

    my $modified = s/$pattern/$change_to/gr;

    Where /r stands for 'replaced', or somesuch.

      Would that be equivalent to
      (my $modified = $_) =~ s/$pattern/$change_to/g;
      s/$pattern/$change_to/g; my $modified = $_;

      Caution: Contents may have been coded under pressure.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-11-25 06:44 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (671 votes), past polls