"John W. Krahn" wrote:

> [EMAIL PROTECTED] wrote:
> >
> > I have a text file with 5 or more lines as in:
> >
> > My name is this and that
> > I live in Denver Colorado
> > I live in washington
> > I live in Denver Virginia
> >
> > I am trying to read this file and print each line and each word in reverse order 
> > as in:
> >
> > ainigriv revned ni evil I (the output starts with the last last of the file and 
> > reverse each work as well).
> > Here is what I have done, but does not work:
> >
> > print "Enter a file name:\n";
> > my $file = <STDIN>;
> > open (REGFILE, "$file") or die ("Cannot open file: $file: $!");
> >
> > while(my @line = <REGFILE>) {
> >
> > foreach my $lin(@line){
> > my @lines = $lin;
> > print reverse(@lines);
> > }
> > }
>
> use File::ReadBackwards;
>
> tie *FILE, 'File::ReadBackwards', $file
>     or die "Cannot open $file: $!";
>
> while ( <FILE> ) {
>     chomp;
>     print scalar reverse, "\n";
>     }
>
> __END__

Looks cool, and perfectly tailored to the task.  How is it for handligg muti-charcter 
newlines?

Joseph


-- 
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