in reply to Re: IO::Handles ... any good?
in thread IO::Handles ... any good?

The single command line is quite interesting. However, it's possible to run that command without changing the original file?

Replies are listed 'Best First'.
Re^3: IO::Handles ... any good?
by linuxer (Curate) on Mar 22, 2009 at 19:11 UTC

    Currently I only have this solution for a single file:

    perl -pe '$_.="\n"' file1.txt > file1.new

    It's untested but should read file1.txt and print the modified version into file1.new.

    I have no idea, how to perform this with multiple files in one (simple) command.

    You could still use a shell for loop to perform this upon several files...

    # bash for FILE in *.txt; do perl -pe '$_.="\n"' $FILE > $FILE.new; done

      Windows shell would be

      for %q in (*.txt) do perl -pe"$_.=$/" "%q" > "%q.new"

      And a golfed version would be

      perl -nEsay # 5.10 perl -pe$_.=$/ # <5.10 Windows perl -pe'$_.=$/' # <5.10 bash