D
Daniel Friedman
The bottom of p.594 in the Camel book (3rd edition) says this:
no strict 'refs';
$name = "variable";
$$name = 7 ; # Sets $variable to 7
....but I don't obtain that if I declare the variables with "my".
Here's my code:
no strict 'refs';
my ($variable, $name);
$variable = 1;
$name = "variable";
$$name = 7; # should set $variable to 7
print "\$variable is $variable\n";
.... and this prints for me:
$variable = 1
I've found the code works fine if I don't declare the variables (with
the "my" line). What am I not understanding here?
(I'm using Perl 5.6.0 on RH7.2, in case it makes a difference.)
Thanks very much,
--daniel
no strict 'refs';
$name = "variable";
$$name = 7 ; # Sets $variable to 7
....but I don't obtain that if I declare the variables with "my".
Here's my code:
no strict 'refs';
my ($variable, $name);
$variable = 1;
$name = "variable";
$$name = 7; # should set $variable to 7
print "\$variable is $variable\n";
.... and this prints for me:
$variable = 1
I've found the code works fine if I don't declare the variables (with
the "my" line). What am I not understanding here?
(I'm using Perl 5.6.0 on RH7.2, in case it makes a difference.)
Thanks very much,
--daniel