develooper Front page | perl.perl5.porters | Postings from June 2013

[perl #7505] x operator not copying elements in 'for' list?

Thread Previous | Thread Next
Father Chrysostomos via RT
June 16, 2013 00:48
[perl #7505] x operator not copying elements in 'for' list?
Message ID:
On Thu Aug 09 06:58:20 2001, wrote:
> -----------------------------------------------------------------
> [Please enter your report here]
>         $x = 'abcd';
>         for (($x =~ /./g) x 2) {
>           print chop;
>         }
> This prints "abcd".  I expected it to print "abcdabcd".  Apparently,
> when I chop the first item in the list, it also chops the fifth item.
> I was not expecting this aliasing to occur, if it is indeed occurring.

Considering that the repetition operator has worked this way for years now:

    sub {
        print \$_[0], "\n";
        print \$_[1], "\n"; # same address
    }->(($x) x 2)

I think we should consider this not-a-bug.  Some code could be relying
on it.

(I know this ticket is marked resolved, but it is not fixed, and we
still have a to-do test for it.)


Father Chrysostomos

via perlbug:  queue: perl5 status: resolved

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About