win

 view release on metacpan or  search on metacpan

win.pm  view on Meta::CPAN

package win;
our $VERSION = '0.03';
require Exporter;
our @ISA = qw(Exporter);

sub import {

    my $class = shift;

    ($pkg) = (caller)[0];
    $current = __PACKAGE__;

    $mods = "";

    &rerun unless (@_);

    my @list = split /,/, $_[0];
    my $found = 0;

  
  foreach (@list) {
         # give me everything with or without colons. 
         /([\w\:]+)(.*)/;    
         $pm = "Win32/$1.pm";
 
        # susbstitute the colons with backslashes   
         $pm =~ s/\:\:/\//g;
 
         # give me the last part, which will be the file name, of the first regex. 
         $suffix = $2;
         $suffix =~ s/\s+$//; 

	 # Let's see what we find.
         foreach (@INC) {
          next unless ( -e "$_/$pm" ); 
            open(READ, "$_/$pm") or die "Can't read $_/$pm";
              while ($line = <READ>) {
                  if ( $line =~ /package\s+(Win32.*?);/i) {
                  $mods .= "use $1$suffix;\n";   
                  $found++;  
                  last;
                  }  
                  next;
               }  
         last;      
       } 
  next; 
  } 
  
    # Now we've got to give rerun a mods variable, so what do we do if we found nothing?
    # Remember to let rerun catch any missing modules, not Win32-Die.
    my $diev = 0;
    if  ( ( ($found == 0) && ($#list == 0) ) || 
            ($found != ($#list + 1)) ) { 

      $mods = "";       
      foreach (@list) {     
        $_ =~ s/^\s+//; 
        $_ =~ s/\s+$//; 
        if ($mods .= "use Win32::$_;\n") {
        $diev = 1;
        }
      }
    }
    # Must prevent Win32-Die from interferring with our error catch. 
    unless ($diev) { 
        $mods .= "use Win32::Die;\n";
    } 

    &rerun;



( run in 1.893 second using v1.01-cache-2.11-cpan-aadc1410aed )