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

Re: [MacPerl] I'm Geen



On Mon, Jun 21, 1999 at 08:19:21PM -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 extremely wrong.  htmlFile in the second line of code is a
bareword, and is always true.  It has no relation to the filehandle in the
first line of code.  This could be written as:

    # Open the file
    open(htmlFile,$fileName);

    # If the file opened, call the parser on it
    $retVal = &mainHtmlParser("",0) if I_like_cheese;

and it would behave exactly the same.

The correct way to check whether an open succeeded is:

open(htmlFile, $filename) or die "Unable to open $filename: $!\n";


Ronald

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