in reply to difference between \() and []
perl is assigning to $app in scalar context. So the reference operator \ creates a reference for every element in the list, and returns the last element. Since there are no elements, this is a reference to undef. Considermy $aap = \();
It is helpful to think of a list on the RHS as an initializer that can be evaluated in different contexts.my @a = (1,2,3); my $b = 4; my $aap = \(@a,$b); print Dumper($aap); my $aap = \($b,@a); print Dumper($aap); __OUTPUT__ $VAR1 = \4; $VAR1 = [ 1, 2, 3 ];
-Mark
|
|---|