Hi-
I'm trying to get the value of scalars dynamicly using an array. However, I have to be using strict.
This following code is exactly what I want, except this codes doesn't use "strict"
I give it the name of the scalar, then it retreives the value.
This code is the same, but it uses strict and doesn't work. I get the error: "Can't use string ("month") as a SCALAR ref while "strict refs" in use"
sooo, is there a way to get around all this "my" stuff while still using strict?
I'm trying to get the value of scalars dynamicly using an array. However, I have to be using strict.
This following code is exactly what I want, except this codes doesn't use "strict"
Code:
$month = 5;
$day = 7;
$year = 2005;
my @list = qw( month day year );
foreach my $name (@list){
print ${$name};
}
This code is the same, but it uses strict and doesn't work. I get the error: "Can't use string ("month") as a SCALAR ref while "strict refs" in use"
Code:
use strict;
my $month = 5;
my $day = 7;
my $year = 2005;
my @list = qw( month day year );
foreach my $name (@list){
print ${$name};
}
sooo, is there a way to get around all this "my" stuff while still using strict?