in reply to change all occurances of string1 into string2
There's a bit of a problem in the code. It may or may not affect you though:
#!/usr/bin/perl use strict; use warnings; my $orig="she sells sea shells down by the seashore\n"; my ($new1, $new2) = ($orig, $orig); my %translate=(she=>'shore', shore=>'sell', sell=>'she'); $new1 =~ s/$_/$translate{$_}/g for keys %translate; print $new1; #print join(", ", keys %translate), "\n"; my $FOO='0000'; $translate{$_}=9999-$_ for 1..10; $new2 =~ s/$_/$translate{$_}/g for keys %translate; print $new2; #print join(", ", keys %translate), "\n"; $ perl x.pl she shes sea shells down by the seashe shore shores sea shorells down by the seashore
Uncomment the two print statements to see why...
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom