Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Weighted Calculation

by 2teez (Vicar)
on May 01, 2014 at 19:14 UTC ( [id://1084679]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Weighted Calculation
in thread Weighted Calculation

..but for some reason it's not working. Is the syntax correct?

If you are using perl version 5.10.0 and above, it should work. Of course the syntax is correct.
However, this also work:     $user_weight{$cols[0]} ||= 1;

The Defined-or operator was implemented in perl 5.10.0 check Defined-or-operator

Update:

Oops, I didn't see tye answer before posting mine, I had this post opened, then got distracted with some other things before submitting my post later. Only to refresh and see that mine post was in a way similar to his.
+1 tye all the same.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Replies are listed 'Best First'.
Re^4: Weighted Calculation
by AnomalousMonk (Archbishop) on May 02, 2014 at 00:21 UTC
    However, this also work:   $user_weight{$cols[0]} ||= 1;

    That will fail in the case in which the 'special' assigned weight for a worker is zero (maybe he or she is on vacation that week?): such a worker will be assigned a work-weight of 1.

    Update: Perl versions lacking  // might use exists:
        $user_weight{$cols[0]} = 1 unless exists $user_weight{$cols[0]};

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-25 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found