May I ask how could I list a file contents backward in a new file?

What is your definition of backwards?

I want to list each character of the file backwards.


e.g.,

File_A

hello.
how are you?

File_B

?uoy era woh
.olleh

perl -le 'print reverse <>' some-file-you-want-reversed

perl -le 'print reverse map {join "", reverse split //} <>' some-file-you-want-reversed

Thanks how's the following code.


Regards,
Norman

#!/usr/bin/perl -w
$a= "/location/infilename";
$b="/location/outfilename";

open(IN, $a) || die "cannot open $a for reading: $!";
open(OUT, ">$b") || die "cannot open $b for reading: $!";
while (<IN>) {
  print reverse OUT $_;
}
close (IN) || die "cannot close $a: $!";
close (OUT) || die "cannot close $b: $!";

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to