I want to stop the script as soon as it get an error and stop further execution. In my below “sample script”, step 1 throws an error, and still step 2 get executed. Can any one help me out, I want to do it in the following manner. As on step 1 get error I want to stop the execution of script.

i think i am not using(or not aware of ) proper perl error handling features

Are you certain that step 1 really "throws an exception?". Any error in cmd1212.exe will happen in a child process forked by the system() call. Even if it dies like a dog it shouldn't cause system() itself to die. To debug, try putting the system and SendKeys() commands each in their own eval{} block. Also, your printout might be more revealing if you label the exception:

It's good advice, especially if you develop perl modules for general use; however, exit() has a couple of desirable features. 1) You can control (subject to OS/shell vagueries) the exit status of your program; and 2) unlike croak(), die(), etc., exit() doesn't slplat out a message to the console, which can be important if you want to evaluate your program's STDERR output. YMMV.

Update:

I suppose there's also a philosophical question here: Do you prefer to process errors by throwing and catching exceptions or by evaluating the return status of your subroutines? I prefer the latter. Hence, I almost never write a subroutine that intentionally dies() just to return an error.