# How does “do something OR DIE()” work in Perl?

PERLProgrammingServer Side Programming

#### Perl Online Training

46 Lectures 4.5 hours

#### COMPLETE PERL Programming

11 Lectures 1.5 hours

#### Perl for Beginners: Learn A to Z of Perl Scripting Hands-on

30 Lectures 6 hours

The die() function can be used to stop the script and can be used to display a message to the end user. It can be used at the right side of the OR ( || ) operator and at left side can be any expression like the eval() function.

## Case 1 − Using die() function with no parameter

The following is the output.

Now we can use $! to print the error number and a message to the user in the die() function. ## Case 2 − Use of$! in the die() function

The following is the output.

## Case 3 − Display some message to the end user with the die() function

The following is the output.

Updated on 30-Jul-2019 22:30:23