viewing paste build_lub2 | Perl

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
use warnings;
use strict;
use Path::Iterator::Rule;
 
Main();
 
sub Main {
        my @aBasedir = ();
        if(scalar(@ARGV) < 1){
                print "Please enter Dirlist\n";
                my $sInput = <>; chop($sInput);
                @aBasedir = split(' ',$sInput);
        }
        else { @aBasedir = @ARGV; }
        print "Dirlist given = @aBasedir \n";
        my $fPIR = Path::Iterator::Rule->new;
        my $next = $fPIR->iter(@aBasedir);
        while( my $sCurfile = $next->() ){
                process_file($sCurfile);
        }      
        print "End buildin lub\n";
}
 
sub process_file { my $sCurfile = shift;
#my $sCurfile = $File::Find::name;
        return unless(-f $sCurfile);
        return unless ($sCurfile =~ /.lua/ );
        CompileFile($sCurfile);
}
 
sub CompileFile { my ($sFile) = @_;
        my $sOutputFilane = $sFile;
        $sOutputFilane =~ s/.lua/.lub/;
        print "CC -o $sOutputFilane $sFile\n";
        system("luac -o $sOutputFilane $sFile");
}
Viewed 417 times, submitted by lighta.