Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: How to correctly use a symbolic reference to automatically generate hash names?

by lightoverhead (Pilgrim)
on Mar 04, 2014 at 21:36 UTC ( [id://1076970]=note: print w/replies, xml ) Need Help??


in reply to Re: How to correctly use a symbolic reference to automatically generate hash names?
in thread How to correctly use a symbolic reference to automatically generate hash names?

Thank you for your reply.

However, what I have is a set of hashes such as %wow0, %wow1,%wow2, %wow3, .... That's why I want to use a loop to handle these hashes and I need an automatic way to refer to these hashes and to update info on these hashes.

  • Comment on Re^2: How to correctly use a symbolic reference to automatically generate hash names?

Replies are listed 'Best First'.
Re^3: How to correctly use a symbolic reference to automatically generate hash names?
by davido (Cardinal) on Mar 05, 2014 at 00:02 UTC

    Why on earth would you have %wow1, %wow2, and %wow3, instead of %{$wow[1]}, %{$wow[2]}, and %{$wow[3]}? In other words, instead of:

    %wow1 = ( key => value, key => value ); %wow2 = ( key => value, key => value );

    You could have...

    @wow = ( { key => value, key => value }, { key => value, key => value }, );

    Which is an array of hashes, instead of a bunch of hashes loosely related by naming convention.

    I see no advantage to polluting your package global namespace with variable names that are tricky to manipulate when you could just create a single AoH structure.


    Dave

Re^3: How to correctly use a symbolic reference to automatically generate hash names?
by runrig (Abbot) on Mar 04, 2014 at 21:37 UTC
    I am suggesting to not have a set of hashes named %wow0, %wow1, etc., and to instead do as I have suggested.

      you seemed suggesting to put the names of the hashes in an array then refer them the way you posted.

      is there a way to refer to hashes as I original wanted?

        Yes, use a list of hash refs would do the trick. Thank you for your suggestion.

        I still wondering how I can use soft/symbolic ref to do this.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-04-23 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found