Malcolm, I agree with what Martin has already posted. The only other thing
that I would add is the special variable $! to your open or die statement.
If the open statement fails, this variable will tell you why.

open (FORM,"list.dat") or  die "Can't open file list.dat : $!\n"; 



One other thing Martin did but didn't explain was his line:

while (my $line=<FORM>)

While you can do it your way, @alist = <FORM>, there are two reasons not to.
First, if your file is large, this approach is less efficient and slow
because it will read the entire contents of the file into @alist. This can
take a lot of memory -- if the file is small, it really isn't an issue.
Second, @alist is a global array and, as Martin stated, its generally better
to localize your vars/arrays/hashes when possible - again, this is more
efficient use of memory behind the scenes. Sometimes, though, you may really
want to keep the entire file in an array, but in this situation (and most
others) you will want to parse it line by line.

-Pete
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to