Perl built in exit and print in one command

700 Software picture 700 Software · Feb 21, 2011 · Viewed 8.2k times · Source

I know I can die but that prints out the script name and line number.

I like to do things like die 'error' if $problem;

Is there a way to do that without printing line number stuff?

It would be nice not to have to use braces if($problem){print 'error';exit}

Answer

runrig picture runrig · Feb 21, 2011

Adding a newline to the die error message suppresses the added line number/scriptname verbage:

die "Error\n"