Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!giza.cis.ohio-state.edu!jgreely From: jgreely@giza.cis.ohio-state.edu (J Greely) Newsgroups: comp.lang.perl Subject: Re: Silent Bomb Message-ID: Date: 14 Mar 90 22:05:53 GMT References: <11238@deimos.ADS.COM> <7997@ogicse.ogi.edu> <8005@ogicse.ogi.edu> <8006@ogicse.ogi.edu> Sender: news@tut.cis.ohio-state.edu Reply-To: J Greely Organization: Ohio State University Computer and Information Science Lines: 29 In-reply-to: schaefer@ogicse.ogi.edu's message of 14 Mar 90 21:06:09 GMT In article <8006@ogicse.ogi.edu> schaefer@ogicse.ogi.edu (Barton E. Schaefer) writes: >do 'sub.pl' || die ($@ ne "" ? "$@aborted" : "Can't load sub.pl: $!"); I Like Tom's solution (which sits in the archive in perl/scripts/tchrist/source.pl): sub source { local($file) = @_; local($return) = 0; $return = do $file; die "couldn't do \"$file\": $!" unless defined $return; die "couldn't parse \"$file\": $@" if $@; die "couldn't run \"$file\"" unless $return; } 1; Not one line, but quite effective (it of course uses the "trailing-1" convention for sourced files (is this documented yet?)). Here's my contribution: die "$file: " . ($! > 0 ? $! : $@ ne '' ? $@ : "couldn't run") unless do $file > 0; (no, it doesn't print "Just another Perl hacker,") -- J Greely (jgreely@cis.ohio-state.edu; osu-cis!jgreely)