Skip to content

Commit

Permalink
Perlito5 - js - added minimal Carp module
Browse files Browse the repository at this point in the history
  • Loading branch information
fglock committed Sep 10, 2013
1 parent 2d0e5ef commit 61913e4
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src5/lib/Perlito5/Carp.pm
@@ -0,0 +1,46 @@
package Perlito5::Carp;

# carp - warn of errors (from perspective of caller)
sub carp {
warn @_;
}

# cluck - warn of errors with stack backtrace
# (not exported by default)
sub cluck {
warn @_;
}

# croak - die of errors (from perspective of caller)
sub croak {
die @_;
}

# confess - die of errors with stack backtrace
sub confess {
die @_;
}

sub import {
my $self = shift;
my ($pkg) = caller();
my @exports = @_;

push @exports, 'carp'
unless grep { $_ eq 'carp' } @exports;
push @exports, 'croak'
unless grep { $_ eq 'croak' } @exports;

# print "called from $pkg [ @exports ]\n";

for my $export (@exports) {
*{ $pkg . '::' . $export } = \&{ $export };
}

}

sub unimport {
}

1;

0 comments on commit 61913e4

Please sign in to comment.