Y
Yan Wu
HI,
In the below script, "info1" is never defined but it could still run
correctly.
Is there any way to restrict the use of undefined file handle?
Thanks.
Yan
#!/p/perl/bin/perl -w
#
# Program to open the password file, read it in,
# print it, and close it again.
use strict;
use FileHandle;
my $file;
my @lines;
$file = 'myfile'; # Name the file
open(info1, $file); # Open the file
@lines = <info1>; # Read it into an array
close(info1); # Close the file
print @lines; # Print the array
In the below script, "info1" is never defined but it could still run
correctly.
Is there any way to restrict the use of undefined file handle?
Thanks.
Yan
#!/p/perl/bin/perl -w
#
# Program to open the password file, read it in,
# print it, and close it again.
use strict;
use FileHandle;
my $file;
my @lines;
$file = 'myfile'; # Name the file
open(info1, $file); # Open the file
@lines = <info1>; # Read it into an array
close(info1); # Close the file
print @lines; # Print the array