NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Re: (Score:1)
You can also:
push @array, @{ $x || [] };It is not pretty, but anyway :-)
Igor Sutton
Re: (Score:1)
If
$xis not a long and complex expression, then readability would command to usepush @array, @$x if $x;.Note that the really equivalent code would be this:
Or in 5.10 parlance:
Because the reason that the
forloop doesn’t throw an error is that it because it aliases$_to each element, rather than copying, it has to provide lvalue context on each iteration, which means it must also provide lvalue context to the containe