Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: seeking in hash data structure

by driver8 (Scribe)
on Oct 25, 2006 at 01:33 UTC ( [id://580449]=note: print w/replies, xml ) Need Help??


in reply to seeking in hash data structure

It's not clear from your post what exactly you are trying to do, but I think I have some idea. Is there any reason why something like the following isn't good enough?
$hash{'companies'}{'microsoft'}{'people'}{'steve ballmer'} = 'bills bu +lldog'; $hash{'companies'}{'cross over'}{'supports'} = ['iTunes', 'photo shop' +];
That is, as opposed to:
add_to_hash(\%hash,'scalar','companies-microsoft-people-steve ballmer' +,'bills bulldog'); add_to_hash(\%hash,'list','companies-cross over-supports','iTunes','ph +oto shop');
I'm also not sure what you wanted to accomplish with \$hashref = $%hashref{foobar}, but I think it's wrong in too many ways to even list.

-driver8

Replies are listed 'Best First'.
Re^2: seeking in hash data structure
by Maze (Sexton) on Oct 26, 2006 at 21:16 UTC

    the reason just plonking in a new value using perls syntax instead of rolling our own funtion is the same reason that you would create any function, so that it becomes adaptable. My original idea was to create something that would record a file hierachy in a hash, probably a bad idea, but in any case it's not something you can do using value declarations, not even symreferencesm, because as someone has said they're anonymous

    \$hashref = $%hashref{foobar}
    is very wrong yes, because I was getting confused with the making and dereferencing of references at the same time, I know this now after having every perl program that included the above method crashing spectacularly

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-16 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found