summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChip Salzenberg <chip@atlantic.net>1997-02-18 13:22:00 +1200
committerChip Salzenberg <chip@atlantic.net>1997-02-18 13:22:00 +1200
commit9d17b0a6244cecb9ba7d42c6a1a882fd933f6f45 (patch)
tree21f7ca706ea0bfa3add8a7f39b83cdd0809d396e
parent4fdae80067c447c675a6ac92c7959d2206e207ba (diff)
downloadperl-9d17b0a6244cecb9ba7d42c6a1a882fd933f6f45.tar.gz
[shell changes from patch from perl5.003_26 to perl5.003_27]
Change from running these commands: # this never worked anyway rm -f lib/Fatal.pm rm -f t/lib/fatal.t # ready to patch exit 0
-rw-r--r--lib/Fatal.pm82
-rwxr-xr-xt/lib/fatal.t23
2 files changed, 0 insertions, 105 deletions
diff --git a/lib/Fatal.pm b/lib/Fatal.pm
deleted file mode 100644
index 281474c336..0000000000
--- a/lib/Fatal.pm
+++ /dev/null
@@ -1,82 +0,0 @@
-package Fatal;
-
-use Carp;
-use strict;
-use vars qw( $AUTOLOAD $Debug );
-
-$Debug = 0;
-
-sub import {
- my $self = shift(@_);
- my($sym, $pkg);
- $pkg = (caller)[0];
- foreach $sym (@_) {
- &_make_fatal($sym, $pkg);
- }
-};
-
-sub AUTOLOAD {
- my $cmd = $AUTOLOAD;
- $cmd =~ s/.*:://;
- &_make_fatal($cmd, (caller)[0]);
- goto &$AUTOLOAD;
-}
-
-sub _make_fatal {
- my($sub, $pkg) = @_;
- my($name, $code, $sref);
-
- $sub = "${pkg}::$sub" unless $sub =~ /::/;
- $name = $sub;
- $name =~ s/.*::// or $name =~ s/^&//;
- print "# _make_fatal: sub=$sub pkg=$pkg name=$name\n" if $Debug;
- croak "Bad subroutine name for Fatal: $name" unless $name =~ /^\w+$/;
- $code = "sub $name {\n\tlocal(\$\", \$!) = (', ', 0);\n";
- if (defined(&$sub)) {
- # user subroutine
- $sref = \&$sub;
- $code .= "\t&\$sref";
- } else {
- # CORE subroutine
- $code .= "\tCORE::$name";
- }
- $code .= "\(\@_\) || croak \"Can't $name\(\@_\): \$!\";\n}\n";
- print $code if $Debug;
- eval($code);
- die if $@;
- local($^W) = 0; # to avoid: Subroutine foo redefined ...
- no strict 'refs'; # to avoid: Can't use string (...) as a symbol ref ...
- *{$sub} = \&{"Fatal::$name"};
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-Fatal - replace functions with equivalents which succeed or die
-
-=head1 SYNOPSIS
-
- use Fatal qw(open print close);
-
- sub juggle { . . . }
- import Fatal 'juggle';
-
-=head1 DESCRIPTION
-
-C<Fatal> provides a way to conveniently replace functions which normally
-return a false value when they fail with equivalents which halt execution
-if they are not successful. This lets you use these functions without
-having to test their return values explicitly on each call. Errors are
-reported via C<die>, so you can trap them using C<$SIG{__DIE__}> if you
-wish to take some action before the program exits.
-
-The do-or-die equivalents are set up simply by calling Fatal's C<import>
-routine, passing it the names of the functions to be replaced. You may
-wrap both user-defined functions and CORE operators in this way.
-
-=head1 AUTHOR
-
-Lionel.Cons@cern.ch
diff --git a/t/lib/fatal.t b/t/lib/fatal.t
deleted file mode 100755
index fe2f63d072..0000000000
--- a/t/lib/fatal.t
+++ /dev/null
@@ -1,23 +0,0 @@
-#!./perl
-
-BEGIN {
- chdir 't' if -d 't';
- @INC = '../lib';
-}
-
-print "1..2\n";
-
-sub false { 0; }
-
-sub true { 1; }
-
-use Fatal qw(true false);
-
-eval { true(); };
-
-print "not " if $@;
-print "ok 1\n";
-
-eval { false(); };
-print "not " unless $@;
-print "ok 2\n";