Cool :) 
Thought you said it was going to be hard :)

Mvgr,
Martin

On Sat, 2003-02-08 at 02:08, Sam Ruby wrote:
> I'm attaching the Perl script I wrote to search for license files in 
> case it inspires any suggestions...
> 
> - Sam Ruby
> ----
> 

> #!/usr/bin/perl
> $path = "/home/rubys/jakarta";
> 
> for $file (@ARGV) {
>       open FILE, "<$file";
>       @LINE = <FILE>;
>       close FILE;
> 
>       ($module) = ($LINE[0] =~ /module\s+name="([-\w]+)"/);
>       next unless $module;
>       next unless -d "$path/$module";
> 
>       $license="";
>       $license="license.txt" if -e "$path/$module/license.txt";
>       $license="LICENSE.TXT" if -e "$path/$module/LICENSE.TXT";
>       $license="LICENSE.txt" if -e "$path/$module/LICENSE.txt";
>       $license="LICENSE" if -e "$path/$module/LICENSE";
> 
>       next unless $license;
> 
>       $lastjar = 0;
>       for ($i=0; $i<=$#LINE; $i++) {
>               ($lastjar,$indent) = ($i,$1) if ($LINE[$i] =~ /^(\s*)<jar/);
>               last if $LINE[$i] =~ "</project>";
>       }
> 
>       next unless $lastjar;
> 
>         if ($LINE[$lastjar+1] =~ /^\s*$/) {
>               splice(@LINE,$lastjar+1,0,("\n", "$indent<license 
>name=\"$license\"/>\n"));
>         } else {
>               splice(@LINE,$lastjar+1,0,("$indent<license name=\"$license\"/>\n"));
>         }
> 
>       print "$file\n";
>       open FILE, ">$file";
>       print FILE join("",@LINE);
>       close FILE;
> }
> 
> ----
> 

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to