Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Incomplete Output When Printing Hash

by Laurent_R (Prior)
on Aug 18, 2013 at 19:00 UTC ( #1049934=note: print w/ replies, xml ) Need Help??


in reply to Incomplete Output When Printing Hash

I have no idea if this is going to be of any help, but, quite possibly, this is going to give you a more reasonable count on your data:

my $count = values %myobjtdets;


Comment on Re: Incomplete Output When Printing Hash
Download Code
Replies are listed 'Best First'.
Re^2: Incomplete Output When Printing Hash
by AnomalousMonk (Abbot) on Aug 18, 2013 at 19:49 UTC
    ... quite possibly, this is going to give you a more reasonable count on your data:
    my $count = values %myobjtdets;

    I don't understand. How could
        my $count = values %myobjtdets;
    produce anything at all different from
        my $count = keys %myobjtdets;
    for the  $count scalar?

      Thank you for your comment, AnomalousMonk. I thought that something like:

      print scalar values %hash;

      would return a count on only the defined values. After a quick try, this is obviously not the case. My error.

      This leads me to another possible solution illustrated in the following session under the Perl debugger:

      DB<1> %hash = (jan => 1, feb => 2, mar => undef, apr => undef, may = +> 5); DB<2> x %hash 0 'feb' 1 2 2 'jan' 3 1 4 'may' 5 5 6 'mar' 7 undef 8 'apr' 9 undef DB<3> print scalar grep {defined $_} values %hash; 3 DB<4> print scalar grep {defined $_} keys %hash; 5

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2015-07-07 18:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls