Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Turning numbers to 1!

by jds17 (Pilgrim)
on Jul 03, 2008 at 20:43 UTC ( #695468=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Turning numbers to 1!
Select or Download Code
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://695468]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (19)
As of 2015-07-28 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls