Hi. I need to create a hash wich name is take from a variable value in a code similar to this:
our $variable = 'name01';
no strict 'refs';
our %$variable = ( valorC => 'value03', valorD => 'value04', );
use strict 'refs';
print %$variable, "\n";
But %$variable gives an error (Can't declare hash dereference in "our" at ..., near "$variable =")
How should I do to make it work?
PLEASE, dont't tell me I dont want to do this.
I want to do exactly what I said above. Not to use hash of hashes or anything else. I DO want to use a variable as a hash name and I'm aware of the risks.
Thanks for any help.
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||