
shest75
Novice
Nov 1, 2009, 9:52 AM
Post #7 of 7
(6285 views)
|
Re: [omatza] Reversing the contents of a file
[In reply to]
|
Can't Post
|
|
Bonjour, Updated program : open FILE, $ARGV[0] or die $!; open my $out, '>', $ARGV[1] or die "Can't write new file: $!"; while (<FILE>) { print reverse; print $out scalar reverse;print $out "\n"; } close $out; then perl myfile.pl in.txt out.txt the out.txt file will be created each time. If you want to append data at the end of the file use : open FILE, $ARGV[0] or die $!; open my $out, '>>', $ARGV[1] or die "Can't write new file: $!"; while (<FILE>) { print reverse; print $out scalar reverse;print $out "\n"; } close $out; Bye
(This post was edited by shest75 on Nov 1, 2009, 9:55 AM)
|