Hello and welcome tamaguchi.

One of the best starting point for references that I know of is the perlreftut man page, available online or on your system by issuing the perldoc perlreftut command. It should get you started on solid ground. If you need more infos, the book Learning Perl Objects, References and Modules is an excellent ressource, having 5 chapters about references, from introduction to tricks and recipe-like examples.

After that, if you still have some unanswered questions, there is perlmonks.org. But I'm sure you know about that one already.

Update: completely forgot about the technical part of your question about passing by reference a hash of arrays to a subroutine. Here's how you could do it.

my %HoA = ( foo => [ 'bar', 'baz' ], qux => [ 'thud', 'xyz' ], ); mysub(\%HoA); # pass a reference of the data structure sub mysub { my $hash_ref = shift; # or if you want to directly work with a hash # instead of a reference inside the sub you can use # my %HoA = %{ shift }; # Then you can do your stuff... }

If any of the above code looks unclear to you, start by reading the perlreftut doc, it should all suddenly make sense.

Once you're more at ease with references, you will certainly want to have a look at the Perl Data Structures Cookbook, as well as at the complete references documentation.


In reply to Re: hash of arrays to a subrutine? by Fang
in thread hash of arrays to a subrutine? by tamaguchi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.