Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
go ahead... be a heretic
 
PerlMonks  

Re: Perl Hash Script

by muba (Priest)
on Jan 08, 2013 at 15:59 UTC ( #1012263=note: print w/ replies, xml ) Need Help??


in reply to Perl Hash Script

One thing I can spot right away regards these lines.

foreach my $empnum(sort keys %empwork) { my $periods=0; $periods++; my $hours = 0; $hours += $empwork{$empnum};

Your code boils down to

foreach my $empnum(sort keys %empwork) { my $periods = 1; my $hours = $empwork{$empnum}
I doubt that is what you really want.

Did you mean this instead?

my $periods=0; my $hours = 0; foreach my $empnum(sort keys %empwork) { $periods++; $hours += $empwork{$empnum};


Comment on Re: Perl Hash Script
Select or Download Code
Re^2: Perl Hash Script
by prithviraj (Novice) on Jan 08, 2013 at 16:10 UTC
    I am not getting the exact output for your code Sir.

      I never claimed you it would. I was merely questioning whether your script might suffer from a logical error, and explaining why I think it does. Does it?

      Edit: s/you/it/

        Yes. You are right.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-04-19 05:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (478 votes), past polls