home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / Can.pm < prev    next >
Encoding:
Perl POD Document  |  2003-12-28  |  1.0 KB  |  41 lines

  1. # $File: //depot/cpan/Module-Install/lib/Module/Install/Can.pm $ $Author: autrijus $
  2. # $Revision: #6 $ $Change: 1840 $ $DateTime: 2003/12/28 19:42:02 $ vim: expandtab shiftwidth=4
  3.  
  4. package Module::Install::Can;
  5. use Module::Install::Base; @ISA = qw(Module::Install::Base);
  6. $VERSION = '0.01';
  7.  
  8. use strict;
  9. use Config ();
  10. use File::Spec ();
  11. use ExtUtils::MakeMaker ();
  12.  
  13. # check if we can run some command
  14. sub can_run {
  15.     my ($self, $cmd) = @_;
  16.  
  17.     my $_cmd = $cmd;
  18.     return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
  19.  
  20.     for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
  21.         my $abs = File::Spec->catfile($dir, $_[1]);
  22.         return $abs if (-x $abs or $abs = MM->maybe_command($abs));
  23.     }
  24.  
  25.     return;
  26. }
  27.  
  28. sub can_cc {
  29.     my $self = shift;
  30.     my @chunks = split(/ /, $Config::Config{cc}) or return;
  31.  
  32.     # $Config{cc} may contain args; try to find out the program part
  33.     while (@chunks) {
  34.         return $self->can_run("@chunks") || (pop(@chunks), next);
  35.     }
  36.  
  37.     return;
  38. }
  39.  
  40. 1;
  41.