It's a hash of arrays
%info is a hash
$info{lastnames} is an array reference
To take a page out of Basic debugging checklist tutorial
use Data::Dump;
dd { lastnames => [ qw/ ro sham bo / ] };
__END__
{ lastnames => ["ro", "sham", "bo"] }
Hmm, lets try that again
use Data::Dump;
my %info;
push @{ $info{lastnames} }, 'ro';
push @{ $info{lastnames} }, 'sham';
push @{ $info{lastnames} }, 'bo';
dd \%info;
__END__
{ lastnames => ["ro", "sham", "bo"] }
Thats better. Last demo
use Data::Dump;
my %info;
$info{lastnames}[0] = 'ro';
$info{lastnames}[1] = 'sham';
$info{lastnames}[2] = 'bo';
dd \%info;
__END__
{ lastnames => ["ro", "sham", "bo"] }
Any time you're wondering about something , write yourself a little program like these three :) hashofarrays.01.pl, hashofarrays.02.pl, hashofarrays.03.pl
Does a hash of arrays make sense for your use case, maybe :) maybe @records is a better fit, I can't tell yet
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.