Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

the try/catch example from "Programming Perl" analyzed

by pemungkah (Priest)
on Aug 18, 2004 at 16:54 UTC ( #384038=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub try (&$) {
       my($try, $catch) = @_;
    ...
    }
    
    sub catch (&) { $_[0] }
    
  2. or download this
      try {
         die "phooey";
    ...
      catch {
         /phooey/ and print "unphhoey\n";
      }
    
  3. or download this
      sub identity {
          return $_[0];
      }
    
  4. or download this
       sub example {
          /foo/ and print "foo detected";
    ...
       catch { 
               /foo/ and print "foo detected";
       }
    
  5. or download this
      try { 
        # some code that dies 
    ...
      catch { 
        # pattern match against $_ for die string 
      } 
    
  6. or download this
      try( sub{ 
                # code that dies 
    ...
                     } 
             ) 
      ); 
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://384038]
Approved by Elgon
Front-paged by calin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-08-02 08:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (55 votes), past polls