in reply to using "my" in hash slice

Yes it is legal (pretty dumb, but legal).
But it's NOT work with perl, v5.8.4 built for i686-linux-thread-multi
Of course it works. Sure it does something different, but it works. The real question is what is it supposed to do? If you had written @a{(undef) } = () you'd have gotten the same result. I would guess that this "new" behaviour is the correct behaviour (all expressions which evaluate to undef should be turned into the empty string "").

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^2: using "my" in hash slice
by ccn (Vicar) on Jun 18, 2004 at 10:34 UTC
    If you had written @a{(undef) } = () you'd have gotten the same result.
    But (undef) and () are the different things. The first one is not empty list, but the second one is empty.
    BTW the following code gives the identical results with all versions of the perl (no warninigs, empty hash)
    perl -wle 'use Data::Dumper; my %a; @a{()} = (); print Dumper(\%a)'
      Ok, so I misspoke. It seems that in that particular context the empty list is being upgraded to an empty string, which I guess would count as a bug.
      update: Seeing how the example is pretty dumb, I wouldn't count it as much of a bug :)(its probably trivial to fix, but its just so dumb it wouldn't matter if its never fixed) At least this does the right thing :
      perl -wle 'use Data::Dumper; my %a; @a{my @b,1} = (); print Dumper(\%a +)' perl -wle 'use Data::Dumper; my %a; @a{my @b,1} = (1,2); print Dumper( +\%a)'

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.