Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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};

Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2016-10-27 23:14 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (372 votes). Check out past polls.