42 lines
952 B
Perl
42 lines
952 B
Perl
|
#!/usr/bin/perl
|
||
|
use strict;
|
||
|
use autodie;
|
||
|
use warnings;
|
||
|
use File::Compare;
|
||
|
use File::Basename;
|
||
|
no warnings 'once';
|
||
|
|
||
|
foreach my $file (@ARGV) {
|
||
|
if (-e $file) {
|
||
|
my $data = process_file($file);
|
||
|
open(MYOUTPUTFILE, "+>$file.bak") or die "Error opening output file $!";
|
||
|
print MYOUTPUTFILE $data;
|
||
|
close(MYOUTPUTFILE);
|
||
|
if (compare($file, "$file.bak") != 0) {
|
||
|
print "Processed $file\n";
|
||
|
}
|
||
|
unlink $file;
|
||
|
rename "$file.bak", $file;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
sub process_file {
|
||
|
my($filename) = "$_[0]";
|
||
|
open(MYINPUTFILE, "<$filename") or die "x $!";
|
||
|
my($data) = "";
|
||
|
while(<MYINPUTFILE>) {
|
||
|
s/\s*$//;
|
||
|
my($line) = $_;
|
||
|
if($line !~ /^\s*$/) {
|
||
|
$data = $data . "$line\n";
|
||
|
}
|
||
|
}
|
||
|
close(MYINPUTFILE);
|
||
|
chomp($data);
|
||
|
if ($data !~ /^\s*\/\*\*/) {
|
||
|
my $basename = basename($filename);
|
||
|
$data = "/**\n * \@file $basename\n * \@author Austen Adler (agadler)\n * TODO: Description\n */\n$data";
|
||
|
}
|
||
|
return $data;
|
||
|
}
|