| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
Debconf::Path - path searching |
| 6 |
|
| 7 |
=cut |
| 8 |
|
| 9 |
package Debconf::Path; |
| 10 |
use warnings; |
| 11 |
use strict; |
| 12 |
use File::Spec; |
| 13 |
|
| 14 |
=head1 DESCRIPTION |
| 15 |
|
| 16 |
This module helps debconf test whether programs are available on the |
| 17 |
executable search path. |
| 18 |
|
| 19 |
=head1 METHODS |
| 20 |
|
| 21 |
=over 4 |
| 22 |
|
| 23 |
=item find |
| 24 |
|
| 25 |
Return true if and only if the given program exists on the path. |
| 26 |
|
| 27 |
=cut |
| 28 |
|
| 29 |
sub find { |
| 30 |
my $program=shift; |
| 31 |
my @path=File::Spec->path(); |
| 32 |
for my $dir (@path) { |
| 33 |
my $file=File::Spec->catfile($dir, $program); |
| 34 |
return 1 if -x $file; |
| 35 |
} |
| 36 |
return ''; |
| 37 |
} |
| 38 |
|
| 39 |
=back |
| 40 |
|
| 41 |
=head1 AUTHOR |
| 42 |
|
| 43 |
Colin Watson <[email protected]> |
| 44 |
|
| 45 |
=cut |
| 46 |
|
| 47 |
1 |