in reply to Re^2: Trouble using exit codes
in thread Trouble using exit codes

If you actually do want to exit the program, and pass some exit code to the calling process, there's nothing wrong with using exit.  In the above snippet, you could place the exit after the print, for example.

... print "exit code: $exitcode, message: '$msg'\n"; exit $exitcode;

But note that negative exit codes are typically interpreted unsigned, e.g. in a Unix shell, -1 would turn into 255  (-2 into 254, etc.):

$ perl -e "exit -1" $ echo $? 255

Replies are listed 'Best First'.
Re^4: Trouble using exit codes
by justkar4u (Novice) on Apr 06, 2011 at 21:07 UTC
    You are Awesome !! Thank you Thank you.:) I hope I can program like you one day. "Bows" - Ram