in reply to Re: Selecting Correct Array
in thread Selecting Correct Array
No it won't.
Symbolic references only work for globals, because lexicals (what "my" makes) don't have symbol table entries, so ${"menu_$foo"} can't find them.
If you tried your code, you'd see it prints nothing.
Try this instead:
But as I mentioned above, don't do this. It only works if you turn off strict 'refs', and then the compiler can't tell you if you're referencing something that's not there, as you did.our @menu_info; my $foo; $menu_info[1] = "hello"; $foo = "info"; print ${"menu_$foo"}[1];
|
|---|