http://www.perlmonks.org?node_id=186589


in reply to breaking from a script

To exit from the script you can use  exit $errorcode;
I would use a reg ex to match that string i guess. Or check the error level of the adduser command (which is probably a better option for what your trying to do). Do this using perls built in system call.If you try to add a user that already exists it probably wont exit with 0.
if (!system("adduser bob")) { exit 0; } else { exit 122 }