Hello Derek,

> can I email you from know on??? :  )  You are so through!  Thank you! 

No, I would prefer that you always reply to the list. First reason is that
other beginners can benefit from our exchange (and the mails end up in a
searchable archive), second is that if I'm not there (or for the many
subjects which I don't know that well, I still think of myself as a beginner
too), others can reply to you.

I just saw that your message contained some questions which I could answer,
and I figured I would give the others who are always answering questions
(you know who you are!) a short break. :-)


> My reasoning for the array was so that I can only and easily print 
> out specific elements.  So do you still suggest just using the while 
> construct instead of the array assuming memory is not an issue? 

Well, if you're going to be using those elements only once (i.e. your
processing of the file is sequential) I would still suggest reading one line
at a time. You never know when you might start using very large files
instead of small ones... 

But of course, if you're going to read only one line of the file, and you
already know the line number, you might want to slurp into an array and get
the specific line right away. I think there was a discussion about this (how
to get to a specific line number directly without looping) on this list not
long ago. Search the archives to find it.

Also, if you're going to do something to one line, then go to another one,
and then might come back to the first one, using an array will be easier. If
you don't, you'll have to seek to the beginning of the file and restart your
loop to go back to the first line you processed. Such non-sequential
processing on a file is usually done with the whole file in memory, i.e.
with slurping.

It all depends. Both are valid methods, but in general reading one line at a
time leads to fewer problems if what you're doing can be done with that
method.

Hope this helps. Just remember, in programming nothing is black and white.
Keep an open mind, and remember that techniques you dismissed for solving
one problem might turn out to be the best way to solve another one.

J-S

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