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

Re: seeking in hash data structure

by driver8 (Scribe)
on Oct 25, 2006 at 01:33 UTC ( #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.


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?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2022-05-25 19:26 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (90 votes). Check out past polls.