Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2018-06-24 13:52 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.