Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Array reference problem

by JavaFan (Canon)
on Jul 07, 2009 at 16:04 UTC ( [id://777921]=note: print w/replies, xml ) Need Help??


in reply to Array reference problem

$name = sprintf "%s%s",'descriptor_array',$array_no; print @$name;
Since $name contains a string, @$name will access a package variable - not a lexical variable introduced with my.

Either use our, or use a hash (or array) of arrays, instead of using the names directly.

Replies are listed 'Best First'.
Re^2: Array reference problem
by hda (Chaplain) on Jul 07, 2009 at 16:14 UTC
    Thanks, that worked. However, I can't understand why one of these two 'families' of arrays can be accessed whereas the other not.
      Because only for package variables does the lookup happen at runtime.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://777921]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-06-18 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.