Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: nested arrays

by aufrank (Pilgrim)
on Aug 14, 2002 at 19:11 UTC ( #190200=note: print w/replies, xml ) Need Help??


in reply to nested arrays

your question could be more clear, it would be especially helpful if you were to include some code for us to work with. check ybiC's homenode for a lot of good links on asking questions. That said, to put an arrayref into a hash, try:

use Data::Dumper; my @array1 = qw /foo bar baz/; my @array2 = qw /qux quux quuux/; my %hash; $hash{'array1'} = [@array1]; $hash{'array2'} = [@array2]; print Dumper %hash; print $hash{'array1'}[0];

Data::Dumper is really useful for examining your data structures, and is part of the core distribution of perl. The last line shows how you would access an individual element of the array. Also, check out Perl Datastructures Cookbook for more information on creating complex data structures, and perlref for information on using references in perl.

hth,
--au

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2022-12-03 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?