When we want to abort the program then we can use die.If we will use "\n" at the end then it will not explain the line number where it has aborted and other info. If you will not use "\n" at end then it will give the info.
Program Code:
# !/Perl/bin/perl
print ("Enter 0 or 1\n");
$input=<STDIN>;
if($input==0){
die("Hi i am about to die\n");
}
else{
die("Hi i am about to die with info about the program");
}
# !/Perl/bin/perl
print ("Enter 0 or 1\n");
$input=<STDIN>;
if($input==0){
die("Hi i am about to die\n");
}
else{
die("Hi i am about to die with info about the program");
}
Output:
0 comments:
Post a Comment