in reply to Assigning the result of a chomp to the chomped var itself.

It appears to be fixed in perl-5.21.6: i.e. 5.21.5 outputs 0,1,1 while 5.21.6 outputs 1,1,1.

Dave.

  • Comment on Re: Assigning the result of a chomp to the chomped var itself.

Replies are listed 'Best First'.
Re^2: Assigning the result of a chomp to the chomped var itself.
by choroba (Cardinal) on Nov 26, 2014 at 15:19 UTC
    Oh, thanks for the info. Probably mentioned in the delta:
    Assignment to a lexical scalar is often optimised away (as mentioned under "Performance Enhancements"). Various bugs related to this optimisation have been fixed. Certain operators on the right-hand side would sometimes fail to assign the value at all or assign the wrong value, or would call STORE twice or not at all on tied variables. The operators affected were $foo++, $foo--, and -$foo under use integer, chomp, chr and setpgrp.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^2: Assigning the result of a chomp to the chomped var itself.
by 5plit_func (Beadle) on Nov 26, 2014 at 15:13 UTC

    Just felt is should share my findings.

    When i ran the code in Perl version 5.16.1 developed by activestate i got the following results.

    $x = 0   $y = 1  $z = 0