Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Complex Data Structure Suggestions Wanted

by djohnston (Monk)
on Jun 07, 2005 at 17:43 UTC ( #464403=note: print w/replies, xml ) Need Help??


in reply to Complex Data Structure Suggestions Wanted

Here are a couple more alternatives...
sub ReadSource{ my ($DataSource, $HashRef) = @_; my @Data = get_data(); for (@Data){ my $item = $HashRef->{$_} ||= []; push( @$item, $DataSource ); } }
..or..
sub ReadSource{ my ($DataSource, $HashRef) = @_; my @Data = get_data(); push( @{ $HashRef->{$_} ||= [] }, $DataSource ) for @Data; }
There really is more than one way to do it!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2020-12-01 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (20 votes). Check out past polls.

    Notices?