Acme-DoOrDie
view release on metacpan or search on metacpan
lib/Acme/DoOrDie.pm view on Meta::CPAN
qw(croak);
our $VERSION="0.001";
sub do_or_die ($ )
{
my($name) = @_;
my($want, @result, $result, $syntax);
if (!defined($name) || $name eq "") {
croak("Missing or undefined argument to require");
}
$want = wantarray();
if ($want) {
@result = do($name);
} elsif (defined($want)) {
$result = do($name);
} else {
do($name);
}
$syntax = $@;
lib/Acme/DoOrDie.pm view on Meta::CPAN
do_or_die("config.pl");
=head1 DESCRIPTION
Error handling for the C<do(FILENAME)> built-in function is
inconvenient. The main problem is that you need to examine more than
just the return value to distinguish a file-not-found condition from a
successful invocation of a file that ends with these two statements:
$! = ENOENT;
undef;
(The L<autodie> module can't help you since it doesn't support the
C<do> function.)
This module provides the replacement function C<do_or_die> that reports
any error by throwing an exception. The same function is also available
under the alias C<do> (not exported by default).
=head1 EXPORTS
t/confuse.pl view on Meta::CPAN
use Errno
qw(ENOENT);
$! = ENOENT;
undef;
( run in 2.278 seconds using v1.01-cache-2.11-cpan-d80b1682f3f )