Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

drefty

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

TryCatch: simple try catch block in perl

   1  
   2  ### begin_: file metadata
   3      ### <region-file_info>
   4      ### main:
   5      ###   - name    : TryCatch: try catch block
   6      ###     desc    : a simple try-catch block example in perl
   7      ###     date    : created="Thu 2005-12-01 10:58:09"
   8      ###     last    : lastmod="Thu 2005-12-01 10:58:13"
   9      ###     tags    : try catch finally error perl cfTryCatch exception
  10      ### </region-file_info>
  11  
  12  ### begin_: init perl
  13      use strict;
  14      use warnings;
  15  
  16  ### begin_: try-catch block
  17      print "begin \n";
  18      eval{
  19          ### try block
  20          print Non_Existent_Function();
  21      };
  22      if ($@){
  23          ### catch block
  24          print "Failed \n";
  25      };
  26      print "end \n";
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS