in reply to trouble shooting my priority lists

it appears that when I sort my hashes it is replicating into all my hashes. I am clueless about what I am doing wrong.
It's pretty hard to find out what could be wrong in such lengthy code, without you explaining what do you expect, what the code output that you think incorrect, and a set of data sample. One suggestion is to use Data::Dumper to inspect your data structure. And if you already have spotted a portion of your code that smells, it would help the rest of us to help you if you just posted that portion instead of the full script.

Please don't use the Switch module for production, per its own author's advice. Many people have experienced problems using it. Here are some reasons why. But you can use some simpler alternative. I see, there are only two possible branches so you may acutally only need a boolean test.

my $target_days; if ($data{day_name} =~ /fri/i) { $target_days = \%p_list_fridays; $fridays++; } else { $target_days = \%p_list_weekdays; $weekday++; } $target_days->{$data{doc}}++; # instead of # $target_days->{$data{doc}} = $target_days->{$data{doc}}+1;
I'm sure this can be improved, but it's just a quick answer.

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

Replies are listed 'Best First'.
Re^2: trouble shooting my priority lists
by arcnon (Monk) on Jun 15, 2007 at 04:26 UTC
    I did say what I was expecting & what is wrong. Dont need Dumper because I seperated out my hashs to ease trying to debug this. Like I said I think that my 4 sorting routines are messing the hashes up but I dont know how.

    As for pulling a smaller code chunk out.... You cant you need it all to have some sort of context to the issue. Hence I will to explain more concisely what the issue is. Saying
    $p_list_weekends{$a} <=> $p_list_weekends{$b};
    $p_list_weekdays{$a} <=> $p_list_weekdays{$b};
    ect. Is replicationg into all my hashes means nothing without seeing it in context.

    To expound on my explaination:
    %p_list_holidays: should return nothing but names => 0
    %p_list_fridays: all the values added together should be 52
    %p_list_weekends: all the values added together should be 104
    %p_list_weekdays: all the values added together should be 209

    Look at the following it is easy to see that
    1 they are all the same
    2 are not following the above math
    3 the hash %p_list_holidays is NOT accessed once but is populated with the same data as the rest.
    OUTPUT ====================================================== WEEKDAYS ====================================================== >>29: curly_joe >>30: jack >>30: jill >>30: larry >>30: shimp >>30: curly >>30: moe ====================================================== WEEKENDS ====================================================== >>29: curly_joe >>30: jack >>30: jill >>30: larry >>30: shimp >>30: curly >>30: moe ====================================================== FRIDAYS ====================================================== >>30: shimp >>30: curly >>30: moe >>29: curly_joe >>30: jack >>30: jill >>30: larry ====================================================== HOLIDAYS ====================================================== >>30: jack >>30: jill >>30: larry >>30: shimp >>30: curly >>30: moe >>29: curly_joe weekdays:209 weekends: 104 fridays: 52