Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The appropriate reference here is Symbolic references. Code might look similar to the above, though be aware that by declaring $rtf with my, you are creating a lexical variable, not a package variable. This means it will get garbage collected, and may no longer exist by the time you want to access it. Much better than symbolic references are normal ones, e.g.
See Why it's stupid to use a variable as a variable name for why you are opening yourself up for pain. The above also passes strict. In the end, however, these types of games generally raises the specter of an XY Problem. Why do you need a reference to the object? Is this a caching thing, which might be addressed with proper scoping? #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way. In reply to Re: Symbolic Reference in Method Call
by kennethk
|
|