Using grep on undefined array

William Blunn bill+london.pm at blunn.org
Wed Aug 14 09:07:51 BST 2013


On 14/08/2013 01:17, Adrian Lai wrote:
> The use of @$fields is sufficient to autovivify $fields as an array ref.

Hmmm. Ish.

/In the context of a parameter to grep/ (and even this may be a 
misleading condition), the use of @$fields is sufficient to autovivify 
$fields as an array ref.

But in the general case, the use of @$fields may not autovivifiy 
$fields. Consider this:

     $ perl -E 'my $a; say q{@$a = }, @$a; say q{$a = }, $a;'
     @$a =
     $a =

In this case @$a does not autovivify $a.

Regards,

Bill


More information about the london.pm mailing list