Loading ...
Sorry, an error occurred while loading the content.
 

[PBML] Re: Perl: Processing multiple files from the commandline

Expand Messages
  • tlowery@dsioj.dla.mil
    Frank Hale: Here is another example of how to accomplish the process. You may want to look into renaming the input file because of memory. Slurping a whole
    Message 1 of 7 , Nov 16, 1999
      Frank Hale:
      Here is another example of how to accomplish the process. You may
      want to look into renaming the input file because of memory. Slurping
      a whole file could cause problems.


      #
      #
      #

      use strict;

      do { print <<EOP;
      stripcr - Strips the carraige returns from Windows text files.
      By: Frank Hale\n
      Date: 10 Oct 1999\n
      --------------------------------------------------------------
      usage: stripcr.pl [windows text file]
      EOP
      exit;
      } unless @ARGV;


      stripcr($_) for (@ARGV);

      exit;

      sub stripcr {
      my $file = shift;


      open(FILE, "< $file") or die qq{Couldn't read from file: $!\n}; #'

      # Slurping the whole file into memory?
      my @fileBuffer = <FILE>;
      close FILE;

      # Reopen the file, truncating it.
      open(FIX_FILE, "> $file") or die qq{Couldn't write from file: $!\n}; #'
      print FIX_FILE map { tr/\r//d; $_ } @fileBuffer;
      close FIX_FILE;
      }

      __END__
    Your message has been successfully submitted and would be delivered to recipients shortly.