Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I've been struggling with this for about an hour and I feel like I am dancing around the answer, but just not getting it. You can see I have problems understanding references...

I pass over an array in a for loop and want to stuff values into a defined hash. The hash being called is created from a value within the array

for my $i(@asnValues) { my @asnParams = split(/ /,$i); my $asnHash = "asn$asnParams[0]"; }

I'd then like to put other array values into this hash within the same for loop

$$asnHash{risk} = $queueNsp[2];

I receive the error about can't use string as hash ref while strict refs. So I tried

my $asn = "asn$asnParams[0]"; my $asnHash = \%{$asn};

but still it was a no go. Can someone please school me on the correct manner of doing this? I'll beat it into my skull by day's end.

thanks very much -c

In reply to Calling a hash through an array value by c

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2023-03-28 19:09 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (68 votes). Check out past polls.