Y
Yevgeniy K.
I have the following code to open a file:
use strict;
sub open_file {
my ($file, $FILE) = @_;
unless (open ($FILE, ">>$file")) { die "error msg\n" }
}
And at runtime I get: "Can't use string ("LIST") as a symbol ref while
"strict refs" in use"
Maybe my understanding of references is incorrect, but I fail to grasp
why this is a reference. I assign the value of local scalar variable
$FILE to the second argument passed to the subroutine, which in this
case happens to be "LIST"; then use that scalar var instead of a
literal to set the filehandle--what is the problem? Please advise!
Thanks in advance!
use strict;
sub open_file {
my ($file, $FILE) = @_;
unless (open ($FILE, ">>$file")) { die "error msg\n" }
}
And at runtime I get: "Can't use string ("LIST") as a symbol ref while
"strict refs" in use"
Maybe my understanding of references is incorrect, but I fail to grasp
why this is a reference. I assign the value of local scalar variable
$FILE to the second argument passed to the subroutine, which in this
case happens to be "LIST"; then use that scalar var instead of a
literal to set the filehandle--what is the problem? Please advise!
Thanks in advance!