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

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

Expand Messages
  • Greg Webster
    ... Only if you let it...this IS the Perl-beginner mailing list, and as such you can ask any question whatsoever and 99% of the time get an answer you can
    Message 1 of 7 , Nov 15, 1999
    • 0 Attachment
      On Mon, 15 Nov 1999, you formulated thoughtfully:
      > Frank,
      >
      > How do I get off this listserve? It's way over my head. Thanks.

      Only if you let it...this IS the Perl-beginner mailing list, and as
      such you can ask any question whatsoever and 99% of the time get an
      answer you can use...

      However, the answers will depend on the question...a complicated
      question will recieve a complicated answer. A simple question
      recieves a simple answer.

      If you still wish to leave, you can do it on the egroups.com website.

      --
      Greg Webster
      http://www.geekrights.org
      Power to the precocious!
    • 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 2 of 7 , Nov 16, 1999
      • 0 Attachment
        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.