in reply to Hash value modification
Note that the values are not copied, which means modifying them will modify the contents of the hash:
for (values %hash) { s/foo/bar/g } # modifies %hash values
Can you give an example on what you are seeing?
SK
Update: Are you not seeing this behavior?
#!/usr/bin/perl -w my @array = qw(1 hello 2 hello 3 hellome 4 hellothere); my %hash = @array; foreach( values %hash ) { s/hello/hi/g; } print +("$_ = $hash{$_}\n") for (sort keys %hash);
Output
1 = hi 2 = hi 3 = hime 4 = hithere
|
---|