[Chicago-talk] is there a perl which?

Jay Strauss me at heyjay.com
Tue Feb 7 22:02:01 PST 2006


Hi,

Is there a function in Perl analygous to the Unix 'which', for saying where in 
the @INC it will find a package?

I do it like:

#!/usr/bin/perl

(my $module_name = shift) .=  ".pm";
$module_name =~ s/::/\//;

foreach (@INC) {
    my $full = "$_/$module_name";
    if (-e $full) {
        print $full;
        last;
    }
}

But thought there might be a built-in or some magic var I can check

Thanks
Jay


More information about the Chicago-talk mailing list