Annotation of abacus/removeNewLines.pl, revision 1.1

1.1     ! ajvincen    1: use strict;
        !             2: use File::Spec;
        !             3: my @dir_list;
        !             4: $dir_list[0] = "./";
        !             5: my @file_list;
        !             6: my $dir_count = 1;
        !             7: my $current_dir = 0;
        !             8: my $file_count = 0;
        !             9: for $current_dir (@dir_list) {
        !            10:   opendir(DIR, $current_dir);
        !            11:   my @subdirs = File::Spec->no_upwards(readdir(DIR));
        !            12:   for my $subdir (@subdirs) {
        !            13:     my $fileName = $current_dir.$subdir;
        !            14:     if (-d $fileName) {
        !            15:       $dir_list[$dir_count] = $fileName."/";
        !            16:       mkdir("../abacusNew/$fileName/");
        !            17:       $dir_count++;
        !            18:     } else {
        !            19:       if ($fileName =~ m/$\.(css|dtd|js|pl|properties|rdf|txt|xul|xml|html|xsl)/ ) {
        !            20:         $file_list[$file_count] = $fileName;
        !            21:         $file_count++;
        !            22:       }
        !            23:     }
        !            24:   }
        !            25:   $current_dir++;
        !            26:   closedir(DIR);
        !            27: }
        !            28: 
        !            29: my $log = "";
        !            30: for my $fileName (@file_list) {
        !            31:   open (ABACUS, "< $fileName");
        !            32:   my $fileText = "";
        !            33:   while (my $line = <ABACUS>) {
        !            34:     $fileText .= $line;
        !            35:   }
        !            36:   close(ABACUS);
        !            37:   $fileText =~ s/\r\n/\n/g;
        !            38:   if ($fileText =~ m/\r\n/) {
        !            39:     die($fileName . " did not lose all newlines!");
        !            40:   } else {
        !            41:     open (ABACUS_OUT, "> $fileName");
        !            42:     print ABACUS_OUT $fileText or die("Couldn't write file $fileName!\n");
        !            43:     close(ABACUS_OUT);
        !            44:     $log .= "$fileName\n";
        !            45:   }
        !            46: }
        !            47: 
        !            48: open (LOG, ">> newLinesLog.txt");
        !            49: my $time = localtime();
        !            50: print LOG "*** START OF LOG at $time.\nFiles successfully cleared of \\r\\n:\n";
        !            51: print LOG $log;
        !            52: print LOG "*** END OF LOG at $time.\n\n";
        !            53: close (LOG);

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>