BEGIN { push @INC, ".." } use strict 1.04; #### BEGIN { use lib ".."; # or unshift @INC, ".." } use strict 1.04; #### #!/usr/bin/perl -lW # catch all bleeping errors BEGIN { push @INC, ".." } my @TAGS = qw| pedantics refs |; my $ideal_version = 1.04; eval " use strict $ideal_version @TAGS; # fails, strict's VERSION==1.03 "; if ($@ =~ /version $ideal_version required.*BEGIN failed/ism) { warn qq|use strict $ideal_version qw(@TAGS); failed, falling back|; shift @TAGS; # Unknown 'strict' tag 'pedantics' eval "use strict qw|@TAGS|"; # which strict is this?? unless ($@) { print qq|second eval, using strict $strict::VERSION qw(@TAGS) from module |, $INC{"strict.pm"}; } } print qq|main now using strict $strict::VERSION qw(@TAGS) from module |, $INC{"strict.pm"}; if ( grep /pedantics/, @TAGS ) { # newer 'pedantics' related code here # will this run under strict v1.03?? not a chance } else { # workaround for backward compat. # sub pedantics {...}; } if ( grep /refs/, @TAGS ) { # usual 'refs' related code here } else { # quite unlikely to be reached } __END__ __output__ use strict 1.04 qw(pedantics refs); failed, falling back second eval, using strict 1.03 qw(refs) from module /usr/share/perl/5.8/strict.pm main now using strict 1.03 qw(refs) from module /usr/share/perl/5.8/strict.pm #### BEGIN { eval { require Foo::Bar; if ($Foo::Bar::VERSION eq 5.01) { import Foo::Bar qw| ... |; } }; revert() if $@; } #### eval " use Foo::Bar 5.01 qw| ... | "; revert() if $@;