You can use map, I've set this up two ways, the @elements array uses the references the way you use them in your code. I call map to do the substition, at that point you can print it out however you like, I used Data::Dumper so you can see what the var structure looks like. In the second example @elems2 I did away with the references, with subtle changes to the map function(I do not dereference $_) BTW, $_ can be dropped at that point, but I wanted to keep it symmetrical with the other map. Notice how the first Data::Dumper output shows that the elements array contains references to the strings and the second contains the strings.

#!/usr/bin/perl use Data::Dumper; $hall_name="Foo's Hall"; $contact_name="Prof Bar"; $contact_email="profbar\@fooshall.edu"; $contact_telephone="1'234'567'8901"; my @elements = ( \$hall_name, \$contact_name, \$contact_email, \$contact_telephone ); my @elems2 = ( $hall_name, $contact_name, $contact_email, $contact_telephone ); map { $$_ =~ s/'//g } @elements; print Dumper(\@elements); map { $_ =~ s/'//g } @elems2; print Dumper(\@elems2); __END__ #Output looks like: $VAR1 = [ \'Foos Hall', \'Prof Bar', \'profbar@fooshall.edu', \'12345678901' ]; $VAR1 = [ 'Foos Hall', 'Prof Bar', 'profbar@fooshall.edu', '12345678901' ]; # As you can see the first one contains the references, # And the second does not.

HTH


In reply to Re: Storing an array of variables by pzbagel
in thread Storing an array of variables by CodeJunkie

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.