Using strict is a method to ensure you are using solid programming practices in your Perl. You can disable the use of strict, but its probably not the best idea in the world. When doing file operations using strict, I often find its difficult to ensure that my file handles are being opened and closed correctly. To resolve this issue, I usually use a Perl Module called FileHandle.pm. It not only makes it easier to handle file manipulation, but it also adds some nice features that work in conjunction with file locking (flock) that ensure file integrity.
I would say that if you only open one file in your entire program, that FileHandle.pm is not needed, just be sure to declare your variables. To enable FileHandle.pm, try the following code snippet as needed:
Code:
use strict;
use FileHandle;
my ($fh, $var1, $var2, $etc);
$fh = new FileHandle;
$fh->open("< file.txt") or die "Could not open file"; # Opens a file for reading
print <$fh>;
$fh->close;
There are alot of other nice functions with the module, so if you're looking for some extra power for your file handling functions, be sure to check your PERLDOC. Yes, learning from the PerlDoc is one of the best ways to learn Perl.
Hope this is useful,
------------------
Fred Hirsch
Web Consultant & Programmer
[This message has been edited by fhirsch (edited January 19, 1999).]