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

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]
[Perl300]: I have a quick question about the Meta CPAN
[Perl300]: On any modules pod page, what does the date on top left corner below authors name indicate?
[Corion]: Likely the date of the release of the module
[Corion]: Yep, seems like that

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2017-12-11 18:01 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (310 votes). Check out past polls.