Elihu has asked for the wisdom of the Perl Monks concerning the following question:
I would expect this code to work, but it doesn't. I've tried explicitly using $_, also:foreach $key (keys (%hash)) { replace ($hash{$key}); }
This one works:sub replace { chomp; s/'/\\'/g; }
Could anyone explain this to me? -Thanks.sub replace { chomp $_[0]; $_[0] =~ s/'/\\'/g; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing values in a hash to a subroutine:
by Anonymous Monk on Feb 02, 2000 at 00:49 UTC | |
|
RE: Passing values in a hash to a subroutine:
by Anonymous Monk on Feb 02, 2000 at 01:00 UTC | |
|
Re: Passing values in a hash to a subroutine:
by Elihu (Novice) on Feb 02, 2000 at 03:34 UTC |