FishingIwishIwas
Technical User
Can someone explain why/how the array @buf is modified in the following simple program. I thought only the variable $item is supposed to be modified.
my @buf = ("a1\n", "a2\n");
print @buf;
foreach my $item (@buf) {
chop $item;
}
print @buf;
#the result is
a1
a2
a1a1
my @buf = ("a1\n", "a2\n");
print @buf;
foreach my $item (@buf) {
chop $item;
}
print @buf;
#the result is
a1
a2
a1a1