I'm still learning Perl, and my current effort is trying to learn how to manipulate elements within a multidimensional array. Specifically, I'd like to loop over a number of arrays, performing the same operation on all the elements of all the arrays. For a test problem I have 2 arrays:

@days=qw(mon tues wed thurs fri sat sun); @cols=qw(red orange yellow green blue indigo violet);
and I want to make all of the letter "e"'s upper case. (e->E)

So, I tried this:

#! /usr/bin/perl @days=qw(mon tues wed thurs fri sat sun); @cols=qw(red orange yellow green blue indigo violet); @vars=( @days, @cols); s/e/E/g for @vars; foreach (@vars) { print "$_\n"; } print "@days\n"; print "@cols\n";
but, obviously it only updates the values in the new array @vars and not the @days or @cols arrays.

Then I tried using array references @vars=( \@days, \@cols);
but that didn't work either (prob 'cause I don't really understand array references, yet).

Is there a simple way to do this?

Thanks


In reply to Regex's and Multidimensional Arrays by Mad_Mac

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.