Wednesday, December 14, 2011

PERL WARN( ) FUNCTION

PERL WARN( ) FUNCTION


 

REVISED: Sunday, March 3, 2013




You will learn how to use the Perl warn( ) function.

I.  PERL WARN( ) FUNCTION

The warn(  ) function and the die(  ) function have the same functionality; however, when the warn(  ) function is used your program is not exited.

The warn(  ) function is better suited for non-fatal messages like low memory or disk space conditions.

If we try to change to the /examples directory and the change fails, the consequences are not fatal because the files can still be written to the current directory.

chdir('/examples') ||
   warn("WARNING: Using current directory instead of /examples: $!\n");
 
If the /examples directory does not exist, the above code displays the following error message:

WARNING: Using current directory instead of /examples:

II.  PERL $!

The $! variable is used in the above error message to have it followed by a display of the appropriate system error message.

You have learned how to use the Perl warn( ) function.

Elcric Otto Circle




-->   -->   -->







How to Link to My Home Page

It will appear on your website as:
"Link to ELCRIC OTTO CIRCLE's Home Page"






No comments:

Post a Comment