Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Perlito5 - js - added minimal Carp module
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|