The die
statement is used to terminate the execution of a code when an error occurs. It causes the code execution to stop and display an error message when an error occurs in the code.
The syntax of the die
statement is given below:
die('error message')
unless(chdir("/etce")) {die "Error: Can't change directory - $!";}
unless
statement to check whether the directory etce
exists. etce
does not exist, the die
statement terminates the execution of the code and causes an error message to be thrown.