First of all how to pass a hash:
# Populate a hash. my %result = some_function(%data); sub some_function { my %passed = @_; my %to_return; # Do stuff with %passed here and populate %to_return return %to_return; }
With this you can do things like this:
my %distribution = degree_distribution(); my %random_distribution_1 = random_distribution(); my %random_distribution_2 = random_distribution(); my %random_distribution_3 = random_distribution(); output(%distribution); output(%random_distribution_1); output(%random_distribution_2); output(%random_distribution_3);
and so on. (I'm not suggesting that those be actual functions you use, but that gives you an idea.)

Before long I predict that having to repetitively work with 3 random distributions will get very old. That's where you'll want to work with more complex data structures. For that read references quick reference and come back if you have any questions.


In reply to Re^3: Tallying appearance of a unique string from hash keys by tilly
in thread Tallying appearance of a unique string from hash keys by jack_j

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.