On Tue, Mar 04, 2003 at 11:24:55AM -0000, Rob Dixon wrote:

<snip>

> > @rgstr=<HoyIn>;
> 
> This puts the <> operator into list context, so it will read
> all of the file, placing separate records into consecutive
> elements of the array. If this is what you want to do, then
> you have finished with the file already and you can close
> it here:

I presume if I change "$/" the definition of what constitutes a record will
change also?  So an element in the array can contain newlines?

<snip>

> However, sucking all of the file into memory may be a
> bad idea, especially if it is a large file. In this case you
> can use a while loop on the filehandle:

I've seen this advice before, but how big is a "large file"?  I mean I know
this depends on the available memory, but presumably a few kilobytes or even
megabytes won't cause too much of a strain?

<snip>

> Since you're using <> in a scalar context here it will read
> individual lines into the $_ variable. The while condition
> will succeed until you reach end-of-file, and the
> conditional
> 
>     if 5..eof
> 
> will succeed on or after line number 5 until end-of-file.

How about if you want to pass lines 5 to 25 into an array, what's the best
way to do that?

Or what I'm really after, how to pass everything between two strings into an
array?  Excuse me asking that on a beginners list, I just suspect there's
some built in function I've missed that will allow me to do that in a couple
of lines.

Hmm, four questions in my first post, sorry.

-- 
FunkyJesus System Administration Team


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to