Help for this page

Select Code to Download


  1. or download this
    sub foo { return [0,1]; }
    my $aref = foo();
    
  2. or download this
    sub foo { return (0,1); }
    my $aref = [foo()];
    
  3. or download this
    sub foo {
        my @rv = (0,1);
    ...
    }
    my $aref  = [foo()]; # wantarray() will be true, so the entire list ge
    +ts passed back and then the square braces create and populate an arra
    +y ref.
    my $aref2 = foo();   # wantarray() will be false, so inside the subrou
    +tine we return a reference to the array.