Permalink
Browse files

Possibility for more than one file

  • Loading branch information...
1 parent 191d39d commit 9844c72af3f91068208d2dcf43ebf89bea3ff1ef @dermesser committed Apr 11, 2012
Showing with 22 additions and 18 deletions.
  1. +22 −18 whitespace.pl
View
40 whitespace.pl
@@ -5,31 +5,35 @@
use utf8;
use File::Copy;
-die("Usage: whitespace.pl <FILE>\n") if scalar @ARGV != 1;
-
-open(my $tempfile,">",".white_tmp");
-open(my $file,"<",$ARGV[0]);
+die("Usage: whitespace.pl <FILE>\n") if scalar @ARGV == 0;
my $pat = qr/^(\t| )+$/;
-my $i = 0;
-while ( my $line = <$file> )
+foreach my $actual_file (@ARGV)
{
- $i++;
+ open(my $tempfile,">",".white_tmp");
+ open(my $file,"<",$actual_file);
- if ( $line =~ $pat )
- {
- #print $i." ".$line;
- print $tempfile "\n";
- } else
+ my $i = 0;
+
+ while ( my $line = <$file> )
{
- print $tempfile $line;
+ $i++;
+
+ if ( $line =~ $pat )
+ {
+ #print $i." ".$line;
+ print $tempfile "\n";
+ } else
+ {
+ print $tempfile $line;
+ }
}
-}
-close($file);
-close($tempfile);
+ close($file);
+ close($tempfile);
-copy(".white_tmp",$ARGV[0]);
+ copy(".white_tmp",$actual_file);
-unlink(".white_tmp");
+ unlink(".white_tmp");
+}

0 comments on commit 9844c72

Please sign in to comment.