Fellow Monks!
I need your help!
In a nutshell I want to sort 12 months of single value data into 12 corresponding arrays. Sure I could do 12 if-then statements, but I would rather do it in a more sleak fashion such as what I would call a variable array naming scheme. The 12 arrays would already be predefined @stat1....@stat12. However, when it comes time to sort the data into its appropriate monthly array I would think that I would need to do something like this @statN, where N is the month number of the array that the value is supposed to go into, i.e. month 2 data would go into the array @stat2. Here is a little bit of non-functional code that I have attempted (by looking around for ideas) :
#!/usr/bin/perl -w use strict; my $month; my $value; $month=2; $value=300; my (@stat1,@stat2,@stat3,@stat4,@stat5,@stat6,@stat7,@stat8,@stat9,@st +at10,@stat11,@stat12); my $arrayname = 'stat'.$month; push @$arrayname, $value; my $nr=@stat2; print "NR $nr\n"; print "$stat2[0]\n";
This is an attempted test of prelim. concepts or so I thought. Could you please advise me as to where or how I am going wrong.
Any help that you can provide will be greatly appreciated.
Thank You In Advance!!

In reply to Constructing Variable Arrayname by Anonymous Monk

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.