in reply to Strange array reference behaviour (bug?)

This is behaviour is due to the fact that foreach loops alias their topic to the current value, as opposed to copying it. So when you modify $test you're changing the actual value that you're iterating over. This can be confusing, as you've noted, but it can also prove to be very handy e.g
my @strs = (' this', ' is', ' a ', ' list '); s/^\s+|\s+$//g for @strs; print "@strs\n"; __output__ this is a list
See. perlsyn for more info.
HTH

_________
broquaint