From: Vincent Pit Date: Fri, 24 Sep 2010 17:59:24 +0000 (+0200) Subject: Only load Carp.pm when throwing an error X-Git-Tag: v0.44~2 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=7ec09aef1ade5d56c2a436093a35447035705e22;p=perl%2Fmodules%2FVariable-Magic.git Only load Carp.pm when throwing an error --- diff --git a/lib/Variable/Magic.pm b/lib/Variable/Magic.pm index 2ad1315..5c04932 100644 --- a/lib/Variable/Magic.pm +++ b/lib/Variable/Magic.pm @@ -5,8 +5,6 @@ use 5.008; use strict; use warnings; -use Carp qw/croak/; - =head1 NAME Variable::Magic - Associate user-defined magic to variables from Perl. @@ -296,7 +294,11 @@ Here's a simple usage example : =cut sub wizard { - croak 'Wrong number of arguments for wizard()' if @_ % 2; + if (@_ % 2) { + require Carp; + Carp::croak('Wrong number of arguments for wizard()'); + } + my %opts = @_; my @keys = qw/data op_info get set len clear free/; push @keys, 'copy' if MGf_COPY; @@ -306,7 +308,8 @@ sub wizard { my $ret = eval { _wizard(map $opts{$_}, @keys) }; if (my $err = $@) { $err =~ s/\sat\s+.*?\n//; - croak $err; + require Carp; + Carp::croak($err); } return $ret; }