G'day Steve,

Welcome to the Monastery.

Without any code, it's not possible to advise how to modify it such that you get the results you want.

In brief, you can access arrays using the original name (@array_original_name):

$ perl -E 'my @name = qw{a b c}; say for @name' a b c

You can create an arrayref and access that with the @$arrayref notation:

$ perl -E 'my $name_ref = [qw{a b c}]; say for @$name_ref' a b c

You can take a reference to an existing array and access that as in my last example:

$ perl -E 'my @name = qw{a b c}; my $name_ref = \@name; say for @$name +_ref' a b c

I suspect you're doing something wrong, given the "$var='name'" you mention; however, as already stated, without seeing your code, I can't help you with that.

Take a look at "perlreftut - Perl references short introduction". At the end of that document, you'll find links to more in-depth information.

Before posting again, plesae see the guidelines in "How do I post a question effectively?"; also consider using an "SSCCE". You'll get much better answers if you provide all the relevant details.

— Ken


In reply to Re: Array naming difference @name @{'name'} by kcott
in thread Array naming difference @name @{'name'} by stevemadden

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.