RE: Is it necessary to open the file again to read its contents.

2009-11-18 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Shawn H Corey [mailto:shawnhco...@gmail.com] > Sent: Tuesday, November 17, 2009 11:03 > To: Parag Kalra > Cc: Perl Beginners > Subject: Re: Is it necessary to open the file again to read > its contents. > > Parag Kalra wrote: >

Re: Is it necessary to open the file again to read its contents.

2009-11-17 Thread Shawn H Corey
Wagner, David --- Senior Programmer Analyst --- CFS wrote: > I guess the bigger question is why loop thru the file multiple > times? You should be able to gather all that you need on one pass and > either move into a hash or array depending on what you need. It may be a > small file now, but

Re: Is it necessary to open the file again to read its contents.

2009-11-17 Thread Parag Kalra
Thanks Shawn - 'seek' was precisely what I was looking for Thanks Telemachus - For the sweet explanation And yes David you have made a very valid suggestion. Thanks for that. Will definitely keep in mind... Cheers, Parag On Tue, Nov 17, 2009 at 11:57 PM, Telemachus wrote: > On Tue

Re: Is it necessary to open the file again to read its contents.

2009-11-17 Thread Telemachus
On Tue Nov 17 2009 @ 11:23, Parag Kalra wrote: > Now if want to again the loop through the contents of the file I was not > able to do the following again: > > while ( ) { > print "$_\n"; > } > > Instead I had to first close the previous file handler and the again open > the file to loop th

Re: Is it necessary to open the file again to read its contents.

2009-11-17 Thread Shawn H Corey
Parag Kalra wrote: > Can't this again closing and opening of file avoided while looping through > the file? See `perldoc -f seek` http://perldoc.perl.org/functions/seek.html -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it i

Is it necessary to open the file again to read its contents.

2009-11-17 Thread Parag Kalra
Hi All, The general procedure which I following to process a files is: open FILE, "my_file.out"; while ( ) { print "$_\n"; } Now if want to again the loop through the contents of the file I was not able to do the following again: while ( ) { print "$_\n"; } Instead I had to first clo