In article <20030807185529.A48669 / linnet.org>,
Brian Candler  <B.Candler / pobox.com> wrote:
>On Fri, Aug 08, 2003 at 01:46:20AM +0900, Rudolf Polzer wrote:
>> he means, that in Perl you can do:
>> 
>>   use Data::Dumper;
>>   @l = qw(one two three);
>>   for my $elem(@l)
>>   {
>>     $elem = 'X' . uc $elem;
>>   }
>>   print Dumper \@l;
>> 
>> which yields
>> 
>>   $VAR1 = [
>>             'XONE',
>>             'XTWO',
>>             'XTHREE'
>>           ];

[...]

>There is some Bad Magic going on in the Perl version; somehow $elem is
>aliasing an element of the array, it is not a normal variable at all.

That's not "bad magic," it's a feature - see the discussion of foreach 
in the perlsyn manual page:

       If any element of LIST is an lvalue, you can modify it by modifying VAR
       inside the loop.  Conversely, if any element of LIST is NOT an lvalue,
       any attempt to modify that element will fail.  In other words, the
       "foreach" loop index variable is an implicit alias for each item in the
       list that you're looping over.

Mike
-- 
mike / stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       | GPG PGP Key      1024D/059913DA 
mike / exegenix.com                  | Fingerprint      0570 71CD 6790 7C28 3D60
http://www.exegenix.com/           |                  75D2 9EC4 C1C0 0599 13DA