use Devel::CheckLib; $expat_libpath = $ENV{EXPATLIBPATH} || ''; $expat_incpath = $ENV{EXPATINCPATH} || ''; my @replacement_args; foreach (@ARGV) { if (/^EXPAT(LIB|INC)PATH=(.+)/) { if ( $1 eq 'LIB' ) { $expat_libpath = $2; } else { $expat_incpath = $2; } #push(@replacement_args, "$1=$2"); } else { push( @replacement_args, $_ ); } } @ARGV = @replacement_args; # ** I am using check_lib_or_exit() for verbosity check_lib_or_exit( # fill in what you prompted the user for here lib => [qw(expat)], header => ['expat.h'], incpath => $expat_incpath, ( $expat_libpath ? ( libpath => $expat_libpath ) : () ), );