# S.Chudley (www.chudley.me) : Replace tabs with spaces in source code my $l_extensions = "cc|c|hh|h"; &do_dir("."); sub do_dir { my $a_path = shift; chomp(my @l_files = `dir /B $a_path`); foreach my $l_name (@l_files) { my $l_file = $a_path."\\".$l_name; if (-f $l_file and $l_file =~ m/\.($l_extensions)$/) { my $l_tfile = $l_file.".tmp"; print "Processing $l_file...\n"; open(INF, $l_file); open(OUTF, ">".$l_tfile); while (my $l_line = ) { if ($l_line !~ m/^\s*\/\// and $l_line !~ m/^\s*\*/ and $l_line !~ m/^\s*\/\*/ and $l_line !~ m/^\s*#/ and $l_line !~ m/^\s*$/) { $l_line =~ s/\t/ /g; } print OUTF $l_line; } close(OUTF); close(INF); `copy $l_tfile $l_file`; if ($? != 0) { die "Failure with copy on $l_tfile to $l_file!"; } `del $l_tfile`; if ($? != 0) { die "Failure to delete $l_tfile!"; } } elsif (-d $l_file) { &do_dir($l_file); } } }