Newsgroups: comp.lang.perl
Path: utzoo!utgpu!cunews!bnrgate!bmers145!friedman
From: friedman@chekov.UU.NET (Barry Friedman)
Subject: Re: Signal handlers, scoping & control confusion
Message-ID: <1991Mar7.142059.13963@bmers145.bnr.ca>
Summary: Exception mechanism inconsistant
Sender: news@bmers145.bnr.ca
Reply-To: friedman%chekov@uunet.uu.net
Organization: Northern Telecom Ltd.
References: <lgy.668295480@newton> <11708@jpl-devvax.JPL.NASA.GOV>
Date: Thu, 7 Mar 91 14:20:59 GMT

In article <11708@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes:
>
>As Tom mentioned, eval '&some_routine' is the approved method of trapping
>exceptions.  Use "die" to raise exceptions.
>

An 'exit' issued in an eval'd routine is not trapped.  IMNSHO it should be.

here's an example:

#!/usr/bin/perl

sub test1 { die("bailing out"); }
sub test2 { exit; }

eval "&test1"; print "test1 returned: ",$@,"\n";
eval "&test2"; print "test2 returned: ",$@,"\n";

prints: 

test1 returned: bailing out at /users/friedman/tstp line 6.

--
Barry Friedman                INTERNET: friedman%chekov@uunet.uu.net
Phone: (613) 782-2389         UUCP: ...!uunet!chekov!friedman
Emax Computer Systems Inc.  440 Laurier Ave. W., Ottawa, Ont. Canada K1R 5C4
