viewing paste build_lub | 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
use warnings;
use strict;
use File::Find;
 
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";
    find(\&process_file, @aBasedir);
    print "End buildin lub\n";
}
 
sub process_file { 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 1290 times, submitted by lighta.