http://www.perlmonks.org?node_id=695468


in reply to Turning numbers to 1!

In the line
@{$set_S[$s]} = @{$set_S[$s]} + $epsilons[$s];
the addition creates a scalar context for the right-hand side, in which
@{$set_S[$s]} = 1.
To get what you want, write
@{$set_S[$s]} = $set_S[$s] + $epsilons[$s];
instead.

Replies are listed 'Best First'.
Re^2: Turning numbers to 1!
by alexm (Chaplain) on Jul 03, 2008 at 20:56 UTC
    $set_S[$s] + $epsilons[$s];
    You forgot that $set_S[$s] is an array reference; moritz pointed out the right way to access the value.
      Thanks, you are right, I focused on the scalar context and did not finish to examine the expression correctly.