in reply to Dereference of undefined value OK under strictures?

My guess is auto vivification
$ perl -wMstrict -le 'sub foo { return @_; } ;; my $ar; print foo(@$ar); print $ar;' ARRAY(0xada8b410) $

The aliasing is bypassing the strict check.

Something like this at least ... ;)

Update

DB<12> use strict;print @$b Can't use an undefined value as an ARRAY reference at (eval 39)[/data/ +data/com.termux/files/usr/lib/perl5/5.28.2/perl5db.pl:738] line 2. DB<13> use strict;print @$b=(1..3) 123 DB<14> p $b ARRAY(0xb0a92180) DB<15>

I wasn't too wrong, strict tolerates it as long as it is an lvalue. And aliasing seems to have this effect.

HTH! :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^2: Dereference of undefined value OK under strictures?
by AnomalousMonk (Archbishop) on Jun 28, 2019 at 21:28 UTC
    ... auto vivification ... strict tolerates it as long as it is an lvalue ... aliasing seems to have this effect.

    Ah, yes! And now that you mention it, I vaguely remember a previous discussion along these lines. Thanks!


    Give a man a fish:  <%-{-{-{-<

Re^2: Dereference of undefined value OK under strictures?
by afoken (Chancellor) on Jun 30, 2019 at 11:05 UTC
    DB<12> use strict;print @$b Can't use an undefined value as an ARRAY reference at (eval 39)[/data/ +data/com.termux/files/usr/lib/perl5/5.28.2/perl5db +.pl:738] line 2. DB<13> use strict;print @$b=(1..3) 123 DB<14> p $b ARRAY(0xb0a92180) DB<15>

    Using $a or $b triggers a special case for sort. This can be seen by using some other variable name instead:

    >perl -w -Mstrict -E 'say @$b' Can't use an undefined value as an ARRAY reference at -e line 1. >perl -w -Mstrict -E 'say @$c' Global symbol "$c" requires explicit package name (did you forget to d +eclare "my $c"?) at -e line 1. Execution of -e aborted due to compilation errors. >perl -w -Mstrict -E 'say @$b=(1..3)' 123 >perl -w -Mstrict -E 'say @$c=(1..3)' Global symbol "$c" requires explicit package name (did you forget to d +eclare "my $c"?) at -e line 1. Execution of -e aborted due to compilation errors. >

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      Yes I kept it short, but what's your point?

      We are testing against strict refs not vars.

      $ perl -w -Mstrict -E 'my $c; say @$c' Can't use an undefined value as an ARRAY reference at -e line 1. $ perl -w -Mstrict -E 'my $c; say @$c=(1..3)' 123 $

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice