in reply to Re^3: Meaning of this Filehandle Error?
in thread Meaning of this Filehandle Error?
The exit function, on the other hand, makes it possible to exit the program gracefully, with no error message. To tell the truth, I do not use it very commonly, because my programs usually exit naturally upon completion, but it sometimes happens that you just want to exit early (for example if you figure out that the situation you are examining is OK and that running the program is in the current case useless.
Having said that, the exit function may take a parameter, which will give some information to the operating system on whether the program was successful or not. At least under Unix or Linux, exiting with a 0 value usually indicates successful completion, whereas any other value usually indicates an error (but that's just a common convention, you could do it the other way around if you wished, although I would not recommend to do that, it would make things rather obscure and somewhat obfuscated). This enables the calling script (say a shell script) to figure out whether the program was successful and take appropriate actions depending on that.
|
|---|