@@ -9,7 +9,7 @@ package Object::Util;
99our $AUTHORITY = ' cpan:TOBYINK' ;
1010our $VERSION = ' 0.004' ;
1111
12- use Carp qw( croak ) ;
12+ use Carp qw( carp croak ) ;
1313use List::Util 1.29 qw( pairkeys pairvalues ) ;
1414use Scalar::Util 1.23 qw( blessed reftype ) ;
1515
@@ -365,16 +365,26 @@ sub setup_for :method
365365sub import :method
366366{
367367my $me = shift ;
368+ my (%args ) = @_ ;
368369my ($caller , $file ) = caller ;
369370
370- if ($file ne ' -e' and eval { require B::Hooks::Parser })
371+ $args {magic } = " auto" unless defined $args {magic };
372+
373+ if ($file ne ' -e'
374+ and $args {magic }
375+ and eval { require B::Hooks::Parser })
371376{
372377my $varlist = join ' ,' , $me -> sub_names;
373378my $reflist = join ' ,' , map " \\ $_ " , $me -> sub_names;
374379B::Hooks::Parser::inject(" ;my($varlist );$me \- >setup_for($reflist );" );
375380return ;
376381}
377382
383+ if ($args {magic } and $args {magic } ne " auto" )
384+ {
385+ carp " Object::Util could not use magic; continuing regardless" ;
386+ }
387+
378388my %subs = $me -> subs;
379389for my $sub_name (sort keys %subs )
380390{
@@ -626,6 +636,11 @@ version of Perl, or your Perl is too old to have Internals::SvREADONLY,
626636then it has various fallback routes, but the variables it provides may
627637end up as package (C<our > ) variables, or not be read-only.
628638
639+ If the magic works on your version of Perl, but you wish to avoid the
640+ magic anyway, you can switch it off:
641+
642+ use Object::Util magic => 0;
643+
629644=head1 BUGS
630645
631646Please report any bugs to
0 commit comments