>>>>> "Dave" == Dave Cross <[EMAIL PROTECTED]> writes:

Dave> This came up on Perlmonks earlier today.
Dave> Code A works as you would expect.

Dave> A) push @{ /PAT/ ? \@match : \@nonmatch }, $_ foreach @words;

Dave> Code B gives a strange error (you'd expect it not to work, but you might
Dave> not be able to guess the error).

Dave> B) push @{ /PAT/ ? @match : @nonmatch }, $_ foreach @words;

Dave> Given that Code B generates an error, why does Code C work?

Dave> C) push @{ $_ % 2 ? @odd : @even }, $_ foreach @ints;

Dave> Is it a bug?

Did you see my reply?

... My hunch is that this "works" in the same way that @a->[3]
... "works", in that an array name is sometimes automatically a
... reference to that array, even though the language definition would
... argue otherwise. I've heard it would take deep voodoo to get the
... current interpreter to have the right info to reject that, so
... we'll have to wait until perl 6, where it'll be blessed instead of
... cursed. {grin}

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Reply via email to