[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] How To Scripts



On Tue, 22 Jun 1999 23:50:55 -0500, ken towry wrote:

>    # Open the file
>    open(htmlFile,$fileName);
>    # If the file opened, call the parser on it
>    $retVal = &mainHtmlParser("",0) if htmlFile;

This is absolute rubbish. Somehow, somebody imagined that htmlFile (a
filehandle) would be set to a number or something if the open succeeded,
but to false otherwise. That may be how it works in other languages, but
NOT IN PERL! The htmlFile handle doesn't have a value!

The Perl Way:

>    # Open the file
>    open(htmlFile,$fileName) or die "Cannot open file $fileNAme: $!";
>    $retVal = &mainHtmlParser("",0);

A debugging tip: sprinkle a lot of 

	print STDERR "myvar: $myvar\n";

-ish lines in the script (but not al at the same time, because that
would overflow your brain :-), to see if it behaves as you think it
should. Somehow I doubt if the completed script has ever actually been
tested.

	Bart.

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org