error handling - Is it kosher to assign to $! in Perl? -


Is it OK to assign $ $! On an error in Pearl?

For example,

  if (! (-e $ inputfile)) {$! = "Input file $ inputfile appears absent \ n"; Return return; }  

In this way I can handle all the errors at the top-level.

Thank you.

If you are $! , The system is placed in the error number, which only takes the number then you can actually do this:

  Use the "EEXIST" error; $! = EEXIST; $ Print! Get string values ​​for any defined system error number, but you can not do whatever you want - setting it in an arbitrary string such strings will get you an argument ". .. "Scalair assignment is not numeric in the alert and leave the wrong set on 0. 

The other problem is that $! Can be replaced with any system call, you can rely solely on the trust unless you do not print or do anything else you probably want your own error variable.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -