On Tue, Jan 03, 2012 at 10:35:12AM +0000, Nicholas Clark wrote: > On Tue, Nov 22, 2011 at 10:08:19AM -0500, Matthew Horsfall (alh) wrote: > > Actually, it gets weirder: > > > > perl -we 'print defined(%hash = ())' > > defined(@array) is deprecated at -e line 1. > > (Maybe you should just omit the defined()?) > > > > OP_RV2AV is explicitly ignored, but I don't quite follow the reason, and > > OP_AASSIGN incorrectly catches %hash = () as @array = ()... > > I don't think that your explanation is quite correct. But I'm not sure what > the correct mental model is. In that: > > $ ./perl -e 'sub foo {}; print defined(() = foo);' > defined(@array) is deprecated at -e line 1. > (Maybe you should just omit the defined()?) > > It's conflating lists with arrays, and then using the "array" message when > the thing in question is a list. Oh, wait. I'm missing the point, aren't I? $ ./perl -Ilib -c -e 'print defined (@a = ())' defined(@array) is deprecated at -e line 1. (Maybe you should just omit the defined()?) -e syntax OK $ ./perl -Ilib -c -e 'print defined (%a = ())' defined(@array) is deprecated at -e line 1. (Maybe you should just omit the defined()?) -e syntax OK $ ./perl -Ilib -c -e 'print defined (() = ())' defined(@array) is deprecated at -e line 1. (Maybe you should just omit the defined()?) -e syntax OK Whatever is on the left of the AASSIGN is called "array", whether it's an array, a list or a hash. (I can't think of anything else that's syntactically valid to put there) Nicholas ClarkThread Previous | Thread Next