Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Replacing single quotes to two single quotes inside map

by Anonymous Monk
on Nov 10, 2017 at 21:24 UTC ( #1203142=note: print w/replies, xml ) Need Help??


in reply to Re: Replacing single quotes to two single quotes inside map
in thread Replacing single quotes to two single quotes inside map

Could you explain the pros and cons about changing $data->{$_} rather than making a copy of it?
  • Comment on Re^2: Replacing single quotes to two single quotes inside map

Replies are listed 'Best First'.
Re^3: Replacing single quotes to two single quotes inside map
by duff (Vicar) on Nov 10, 2017 at 22:26 UTC

    The pros/cons are mostly about whether or not you need the original values of $data->{$_} elsewhere since the substitution operation will change the value in-place. If you require the original value prior to the change elsewhere in your code, then clearly you don't want to change them. tybalt89 gave a similar version where the value is returned and not changed, but it requires a relatively recent perl (>= 5.14). I didn't notice if you mentioned a perl version, but some unfortunate people are still on 5.10.1 and such.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1203142]
help
Chatterbox?
and the rats come out to play...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2017-11-25 01:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (355 votes). Check out past polls.

    Notices?