1 |
BEGIN
|
2 |
{
|
3 |
die "Utilities::PathMod: I AM used...","\n";
|
4 |
};
|
5 |
|
6 |
#
|
7 |
# PathMod.pm
|
8 |
#
|
9 |
# Originally Written by Christopher Williams
|
10 |
#
|
11 |
# Description
|
12 |
#
|
13 |
# Interface
|
14 |
# ---------
|
15 |
# new() : A new PathMod object
|
16 |
# Searchpath(path, filename) : return the first occurance of filename in the
|
17 |
# path
|
18 |
|
19 |
package Utilities::PathMod;
|
20 |
require 5.001;
|
21 |
|
22 |
sub new {
|
23 |
my $class=shift;
|
24 |
$self={};
|
25 |
bless $self, $class;
|
26 |
return $self;
|
27 |
}
|
28 |
|
29 |
sub SearchPath {
|
30 |
my $self=shift;
|
31 |
my $path=shift;
|
32 |
my $filename=shift;
|
33 |
|
34 |
my @dirs;
|
35 |
my $dir;
|
36 |
my $file="";
|
37 |
|
38 |
@dirs=split /:/, $path;
|
39 |
foreach $dir ( @dirs ) {
|
40 |
if ( -e $dir."/".$filename ) {
|
41 |
$file=$dir."/".$filename;
|
42 |
last;
|
43 |
}
|
44 |
}
|
45 |
return $file;
|
46 |
}
|