Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: Getting Value from joining 2 variables

by Anonyrnous Monk (Hermit)
on Jan 02, 2011 at 15:33 UTC ( #880078=note: print w/replies, xml ) Need Help??


in reply to Re^3: Getting Value from joining 2 variables
in thread Getting Value from joining 2 variables

... I also included: use strict; use warnings;

Really?  With use strict it should've stopped working

#!/usr/bin/perl use strict; use warnings; our $pax_1 = "foo"; my $plus = 1; my $name = "pax_$plus"; my $paxing = ${$name}; print "$paxing\n"; __END__ Can't use string ("pax_1") as a SCALAR ref while "strict refs" in use +at ./880063.pl line 8.

unless you also disable strict refs, e.g. as follows

#!/usr/bin/perl use strict; use warnings; our $pax_1 = "foo"; my $plus = 1; my $name = "pax_$plus"; my $paxing; { no strict 'refs'; $paxing = ${$name}; } print "$paxing\n"; # "foo"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://880078]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2022-11-26 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?