1.

How will you differentiate between die and exit in Perl?

Answer»

In PERL, the die will PRINT a message to the ‘stderr’ before terminating the program. The exit will only terminate the program without showing anything. The 'die' in Perl is catchable using eval, whereas the 'exit' SIMPLY quits from the process. 

print "ENTER your rate:";  $rate = <STDIN>;  if ($rate < 2000)  {      exit $rate;  }      else  {      print "\n Thanks for the investment! ";  } 

use strict;    use warnings;    open(my $FH, '>', 'sssit/gauravkarlos/perlcode.txt') or die;    print $fh "An example of error handling using die \n";    close $fh;



Discussion

No Comment Found