home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5586 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  838 b 

  1. Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!usc!news!netlabs!lwall
  2. From: lwall@netlabs.com (Larry Wall)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: How do I make traps in perl?
  5. Message-ID: <1992Aug28.190101.9961@netlabs.com>
  6. Date: 28 Aug 92 19:01:01 GMT
  7. References: <1992Aug26.135146.1759@linda.lidac.liu.se>
  8. Sender: news@netlabs.com
  9. Organization: NetLabs, Inc.
  10. Lines: 16
  11. Nntp-Posting-Host: scalpel.netlabs.com
  12.  
  13. In article <1992Aug26.135146.1759@linda.lidac.liu.se> thenglid@linda.lidac.liu.se (Thomas Engstrom) writes:
  14. : Is there anyone that knows how to catch signals in perl? Something like
  15. : "trap" in bourne shell.
  16.  
  17.     $SIG{"INT"} = "CATCHINT";
  18.     ...
  19.  
  20.     sub CATCHINT {
  21.     print "OUCH! Don't DO that!!!\n";
  22.     }
  23.  
  24. Nowadays I often just write
  25.  
  26.     $SIG{INT} = CATCHINT;
  27.  
  28. Larry
  29.