Path: utzoo!attcan!uunet!deimos!ux1.cso.uiuc.edu!uwm.edu!ogicse!hakanson From: hakanson@ogicse.ogi.edu (Marion Hakanson) Newsgroups: comp.lang.perl Subject: Re: Silent Bomb Message-ID: <7997@ogicse.ogi.edu> Date: 14 Mar 90 18:43:16 GMT References: <11238@deimos.ADS.COM> Organization: Oregon Graduate Institute (formerly OGC), Beaverton, OR Lines: 31 In article <11238@deimos.ADS.COM> dglo@deimos.ads.com (Dave Glowacki) writes: >I converted a shell script to a perl script and spent a couple hours >trying to track down the following sort of error. Is there any way >to get error messages from a file included via 'do'? Many people suggest: do 'sub.pl' || die 'error in sub.pl'; but this does not provide informative error messages. E.g. it will not distinguish between the file being missing and it containing a syntax error. So then I tried: do 'sub.pl' || die "Cannot load sub.pl: $!, aborted"; die "$@aborted" if $@; Unfortunately, the first "die" takes effect if the file exists but contains an error, and the "$!" is gibberish in that case (the second "die" never gets to live). My current approach, though verbose, works well and prints meaningful messages: unless ( do 'sub.pl' ) { die "$@aborted" if $@; die "Cannot load sub.pl: $!, aborted"; } I'm sure someone will convert it to a one-liner.... -- Marion Hakanson Domain: hakanson@cse.ogi.edu UUCP : {hp-pcd,tektronix}!ogicse!hakanson