in reply to scalar ref help?

Use package global variables instead of lexical ones:
perl -Mstrict -le 'no strict "refs";use vars qw($x $xr $y); $x = 8;$xr = "x"; $y = $$xr; print $y;'
Heh heh ... but why?

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: scalar ref help?
by slife (Scribe) on Dec 16, 2002 at 16:04 UTC

    perl -Mstrict -le 'no strict "refs";use vars qw($x $xr $y); $x = 8;$xr = "x"; $y = $$xr; print $y;'

    This works because you can only use symbolic references where the variables are visible in the package symbol table; lexical ( i.e. my() ) variables are not (as you can confirm with the Perl debugger).

    Camel 3rd Ed. Ch. 8 refers*

    *Sorry