In your third one-liner example, $a plausibly could be undefined. I think that the OPs problem is that an array-type variable, @a, is being assigned an array reference,$href. Not sure why Perl is complaining about an "undefined variable" in that case, however.