develooper Front page | perl.perl5.porters | Postings from April 2018

Re: [perl #133109] push on scalar forbidden: why?

Thread Previous | Thread Next
From:
L A Walsh
Date:
April 15, 2018 01:44
Subject:
Re: [perl #133109] push on scalar forbidden: why?
Message ID:
5AD2AE6E.3070006@tlinx.org


Philip R Brenan wrote:
> So far you do not appear to be missing anything. *for($a)* was 
> ambiguous under the original implementation
----
    It should never be "ambiguous".  According to the language, it
should always resolve to a single value. In shell, using:

prog='P "perl-%s:", $];
my $aref = [ qw(one two three) ];
for ($aref) {P "%s", $_}'

then (in shell & various perl-bin dirs):

(probs building 5.6.2)

perl-5.8.9/usr/bin> PATH=$PWD:$PATH  perl -MP -CSA -e "$prog"
perl-5.008009:
["one", "two", "three"]

perl-5.10.1/usr/bin> PATH=$PWD:$PATH  perl -MP -CSA -e "$prog"
perl-5.010001:
["one", "two", "three"]

perl-5.12.5/usr/bin> PATH=$PWD:$PATH  perl -MP -CSA -e "$prog"
perl-5.012005:
["one", "two", "three"]

(had probs building 5.14)

>  perl -MP -CSA -e "$prog"
perl-5.016003:
["one", "two", "three"]

(5.18-5.22 not built/tested)

perl-5.24.0/usr/bin> PATH=$PWD:$PATH perl -MP -CSA -e "$prog"
perl-5.024000:
["one", "two", "three"]

/perl-5.26.0/usr/bin> PATH=$PWD:$PATH perl -MP -CSA -e "$prog"
perl-5.026000:
["one", "two", "three"]


(Note: I have 'P' installed from cpan in the versions
tested)

Except for the untested versions, it seems like there is
no ambiguity in "for ($aref) {...}"

Was the problem in one of the untested versions?

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About