in reply to is $i=+3 valid?

You got your answer already to change =+ to +=. However, why do not just experiment a little bit. It is really easy to write:

use strict; use warnings; my $i=0; $i=+3; print "$i\n"; # no errors, so far, prints 3, so we should be fine...? $i=+3; # better try again print "$i\n"; # still prints 3, so something must be wrong! $i=$i+3; # check whether Perl works correctly... print "$i\n"; # prints 6, what a relief

Experiments are fun! (Unless you are a theoretical physicist...)

Replies are listed 'Best First'.
Re^2: is $i=+3 valid?
by Happy-the-monk (Canon) on Jul 05, 2013 at 08:32 UTC

    However, why do not just experiment a little bit.

    Or you make it a rhyme. Need to re-name $i to $e to make it a rhyme:

    ++$e for 1 .. 3;

    Cheers, Sören

    (hooked on the Perl Programming language)

      How to increment by 3, is wondering he (or she). Plus equal or equal plus, what a fuzz! Just try it out and see or stay in the dark will he.