develooper Front page | perl.beginners | Postings from March 2002

Very Basic <> Question

Thread Next
From:
Michael Norris
Date:
March 18, 2002 14:10
Subject:
Very Basic <> Question
Message ID:
20020318220903.9C9C22755@sitemail.everyone.net
Forgive me for such a basic question, I'm brand spanking new to Perl and programming in general.  

This is from the exercises in "Learning Pearl", chapter 6, exercise 1.

The goal is to reverse the order of all the lines of a specified file.

The very simple answer given in the book is as follows:
print reverse <>;

Fair enough, but I wanted to explore and try a different way, I came up with the following which doesn't work...

while (<>) {
@reverselist = reverse <>;
print "@reverselist";
}

This reverses everything, BUT the last line of the given file.  Can someone tell me why this pauses on the last line?

Thanks!






_____________________________________________________________
Surf on! Get a free and secure email account and more @ surfOrbit.com
http://www.surfOrbit.com

_____________________________________________________________
Run a small business? Then you need professional email like you@yourbiz.com from Everyone.net  http://www.everyone.net?tag

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About