B
Bill
I'm trying to use a hash key as a filehandle like so.
#!/usr/local/bin/perl
use strict;
my %buf = (
'F00' => 'foo.dat'
);
&open_files();
exit 0;
sub open_files {
while(my($k,$v)=each(%buf)) {
open ($k, ">$v") || die $!;
}
}
But, I get the following error:
Can't use string ("F00") as a symbol ref while "strict refs" in use at
../try.pl line 14.
I've tried varouis things like \*FOO, *$k ... nothing seems to work.
UNLESS I take out strict, then it works.
Anyone know what's happening here.
Thanks,
Bill
#!/usr/local/bin/perl
use strict;
my %buf = (
'F00' => 'foo.dat'
);
&open_files();
exit 0;
sub open_files {
while(my($k,$v)=each(%buf)) {
open ($k, ">$v") || die $!;
}
}
But, I get the following error:
Can't use string ("F00") as a symbol ref while "strict refs" in use at
../try.pl line 14.
I've tried varouis things like \*FOO, *$k ... nothing seems to work.
UNLESS I take out strict, then it works.
Anyone know what's happening here.
Thanks,
Bill