Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: (dkubb) Re: (3) Printing a hash in a specific order?

by Limbic~Region (Chancellor)
on Mar 15, 2003 at 16:57 UTC ( #243321=note: print w/replies, xml ) Need Help??


in reply to (dkubb) Re: (3) Printing a hash in a specific order?
in thread Printing a hash in a specific order?

dkubb,
Two minor corrections:

  • my $key = each %{$hashref}; - need to dereference the hash
  • my($key) = keys %{$hashref}; doesn't generate a list of keys in memory and assign the first one to key. It assigns all of them in serialized format to the variable. The reason why this works is because there is only one key.

    I also disagree with your analysis that your method would be faster in my example. Each has to retrieve both the key and lookup the value (which we are throwing away). My method is only retrieving a one element list of keys. I do appreciate the effort at making this more efficient. As I said - my first OO project and I know I am making a lot of mistakes. I think the proper way to fix this would be to start over.

    Cheers - L~R

  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: note [id://243321]
    help
    Chatterbox?
    [choroba]: 10 bugs in the tracker?
    [1nickt]: Yes, and recommendation against using it, in the doc for Devel::Declare, on whcih it is based.
    [1nickt]: I asked the new $boiss what I should brush up on before starting work next week, and he named Moo, DBIx::Class and Method::Signatures
    [1nickt]: choroba That's why I asked if anyone is using it :-)
    choroba only has used Moo from the htree
    [1nickt]: Pardonm?

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (6)
    As of 2017-11-24 13:21 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:













      Results (349 votes). Check out past polls.

      Notices?