#!/usr/bin/perl -w -T # install a 'hook' into @INC / see: perldoc -f require BEGIN { unshift @INC, '.'; # replaces 'use lib(.);' unshift @INC, sub { printf "***** TRACE: use %-20s with ARGV=%s\n", $_[1], join(', ', @ARGV); return; }; } BEGIN { print 'before using my module: '.join(', ',@ARGV)."\n" } #use lib qw(.); # removed: would shift hook to 2nd position, disabling tracing use Module; # modified: sub import { shift @ARGV; } use Module2; # just a copy of the unmodified Module.pm BEGIN { print 'after using my module: '.join(', ',@ARGV)."\n" } __END__ > ./script.pl a b c before using my module: a, b, c ***** TRACE: use Module.pm with ARGV=a, b, c beginning my module1: a, b, c ending my module1: a, b, c ***** TRACE: use Module2.pm with ARGV=b, c beginning my module2: b, c ending my module2: b, c after using my module: b, c