in reply to String interpolation problem
Can't declare scalar dereference in my at mytest.pl line 7, near "} =" Execution of mytest.pl aborted due to compilation errors.
The error is because you're trying to declare a lexical variable with 'my' that is a dereferenced symbolic reference. That just doesn't make sense.
What all that means is that you cannot use a symbolic reference as the name of a lexically declared variable. The fact is that lexical variables can't be referred to symbolically. All symbolic refs refer to package globals.
See perlref for details. Also take note that in 99.9% of the common-code situations, you don't really need to be thinking in terms of symbolic references anyway. You can almost always accomplish what your objective is more cleanly with a lexical. If you're interested in "variable names", try using a hash instead, where the keys are represented by those names instead of mucking around in the global symbol table. The global symbol table is, after all, just a glorified hash.
Dave
|
|---|