SPUG: Two errors I need hashing out

David Dyck dcd at tc.fluke.com
Tue Jan 15 12:33:48 CST 2002

On Tue, 15 Jan 2002 at 10:26 -0800, Susanne Bullo <sweetsue at sweethomes.com>...:

> Yes, actually I do intend that - the username to log in is just for the
> database.  Then there are several users within that database so $username
> would have to be overwritten for each one.
> How do I go about checking the return result on my open()?

in perldoc -f open it states
  Open returns nonzero upon success, the undefined value otherwise.
so test the return result.

It also states:

  When opening a file, it's usually a bad idea to
               continue normal execution if the request failed,
               so "open" is frequently used in connection with
               "die".  Even if "die" won't do what you want (say,
               in a CGI script, where you want to make a nicely
               formatted error message (but there are modules
               that can help with that problem)) you should
               always check the return value from opening a file.
               The infrequent exception is when working with an
               unopened filehandle is actually what you want to

If you're doing CGI, you may want to add
 use CGI::Carp;

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/

More information about the spug-list mailing list