B
Bernhard Singer
I just tried something like the following - can someone tell me what is
going on there? To my knowledge, tr should be changing $_, not @list.
my @list = ("foo bar", "say cheese", "granny smith");
my %hash;
for (@list) { $hash{$_} = rand(1); }
for (@list) {
tr/ /_/; # <==== what the hell? why is this changing the values
# in @list?
print "$_\n";
}
for (@list) {
die "Help! $_\n" unless defined $hash{$_};
print $_, ": ", $hash{$_}, "\n";
}
going on there? To my knowledge, tr should be changing $_, not @list.
my @list = ("foo bar", "say cheese", "granny smith");
my %hash;
for (@list) { $hash{$_} = rand(1); }
for (@list) {
tr/ /_/; # <==== what the hell? why is this changing the values
# in @list?
print "$_\n";
}
for (@list) {
die "Help! $_\n" unless defined $hash{$_};
print $_, ": ", $hash{$_}, "\n";
}