[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] getting to the beginning of a opened file



Christian Schwarzfischer,Christian.Schwarzfischer@epunkt.com,Internet writes:
> When I parsed through file with while ($xxx = <FILE>)
> how do I get back to first line without closing and reopening the file?
> 
I've always used...

open(FILE, $filename);   # open a file
@lines = <FILE>;         # plug all the lines into an array (includes "\n"!)
close(FILE);             # close the file
> 

then iterated through the array rather than the file. That way the info's
always there, but the file isn't always open. The first line is always just
$lines[0].

-josh

PS. Not that this will necessarily help you now that you've already written the
open & parse routine...
-----------------------------------------------------------------
                       Open Learning Agency
4355 Mathissi Place, Burnaby, B.C. Canada, V5G 4S8 (604) 431-3000


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch