in reply to map confusion

$_++ is a post increment. The value used is the value $_ contained before being incremented. Unless there is a compelling reason to use the post increment operator you should always use the pre increment operator: ++$_.

Oh, and it's nothing to do with map!

Premature optimization is the root of all job security

Replies are listed 'Best First'.
Re^2: map confusion
by Anonymous Monk on Dec 15, 2015 at 23:53 UTC

    Thank-you. However even with ++$_, @array is still affected in the first case, but not with *. Any thoughts on why?

      Let's say you have a variable $A and you do this:
      $A = 5; $B = $A++; print $A; # prints out 6. $B is 5
      $A = 5; $B = ++$A; print $A; # prints out 6. $B is 6
      $A = 5; $B = $A*2; print $A; # prints out 5. $B is 10
      $A = 5; $B = $A+1; print $A; # prints out 5. $B is 6


      Because ++ changes the original AFTER the operation, and mutiplication just returns the result, without modifying the original.