Re: reading text data to variable

2018-12-28 Thread Jim Gibson
If you want to process lines in a file twice, there are two simple choices: 1. Save the lines in a array the first time you read the file, then traverse the array as many times as you want. This works unless you have a humungous file. 2. Call seek(,0,0) on the file handle and read the file agai

Re: reading text data to variable

2018-12-28 Thread Uri Guttman
On 12/26/18 12:40 PM, Eldon DeHart wrote: I can't figure out how to read each line of text back into my program and assign it to the variable again. Thanks for help in advance. Eldon please show us the code you have and then we can better help guide you. also read the FAQ as that is likely co

Re: Reading text file in reverse order

2004-03-12 Thread John W. Krahn
"R. Joseph Newton" wrote: > > "John W. Krahn" wrote: > > > > use File::ReadBackwards; > > > > tie *FILE, 'File::ReadBackwards', $file > > or die "Cannot open $file: $!"; > > > > while ( ) { > > chomp; > > print scalar reverse, "\n"; > > } > > > > __END__ > > Looks cool, and perfe

Re: Reading text file in reverse order

2004-03-12 Thread R. Joseph Newton
"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

Re: Reading text file in reverse order

2004-03-12 Thread Mame Mbodji
Thank you so that. This is the kind of advice I have been expecting. This is very helpful and I think I will be able to figure it out now. I never intended for the group to do my HMW. I have been with this list for over a year and I learned a lot, but I never posted a question related to my homewor

Re: Reading text file in reverse order

2004-03-12 Thread Mame Mbodji
Thanks for the advice, I will try HARDER and repost if I cannot figure it out! "R. Joseph Newton" wrote: > > Mame Mbodji wrote: > > > This is a hwk, but I never asked for a complete answer > > 1. The term "homework" refers to something fluid, rather than discrete, and > therefore does not take

Re: Reading text file in reverse order

2004-03-12 Thread John W. Krahn
[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 rev

Re: Reading text file in reverse order

2004-03-12 Thread R. Joseph Newton
Mame Mbodji wrote: > This is a hwk, but I never asked for a complete answer 1. The term "homework" refers to something fluid, rather than discrete, and therefore does not take an article ['a' or 'the'] 2. Please do not abbreviate words, unless the abbreviation is a very standard one. I wasted

Re: Reading text file in reverse order

2004-03-11 Thread Randy W. Sims
On 3/11/2004 11:05 PM, Mame Mbodji wrote: This is a hwk, but I never asked for a complete answer. I just needed guidance because I was lost. Thank you anyway. Did you understand the hint I gave earlier? Your code while(my @line = ) { foreach my $lin(@line){ my @lines = $lin; print reve

Re: Reading text file in reverse order

2004-03-11 Thread Mame Mbodji
This is a hwk, but I never asked for a complete answer. I just needed guidance because I was lost. Thank you anyway. Randy W. Sims wrote: Doh! I hope it wasn't his assignment! As a newbie myself it took me about 10 minutes to do that. That's ok. Your solution is the wrong solution ;-) -

Re: Reading text file in reverse order

2004-03-11 Thread Randy W. Sims
Doh! I hope it wasn't his assignment! As a newbie myself it took me about 10 minutes to do that. That's ok. Your solution is the wrong solution ;-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Reading text file in reverse order

2004-03-11 Thread Robert
Randy W. Sims wrote: On 3/11/2004 10:01 PM, [EMAIL PROTECTED] wrote: Sorry, no answers. This sounds like a school assignemnt. But I'll offer a few hints ;-) 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 V

Re: Reading text file in reverse order

2004-03-11 Thread Robert
[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 s

Re: Reading text file in reverse order

2004-03-11 Thread Randy W. Sims
On 3/11/2004 10:01 PM, [EMAIL PROTECTED] wrote: Sorry, no answers. This sounds like a school assignemnt. But I'll offer a few hints ;-) 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

Re: Reading text

2002-01-30 Thread Briac Pilpré
On Tue, 29 Jan 2002 21:56:38 -0600, Michael Pratt wrote: > What is the simplest means of reading a text file line by line. #!/usr/bin/perl -w use strict; open(FILE, '< file.txt') or die "Cannot open file: $!\n"; while(){ # Read each line of file.txt until end of file. # the current lin