Thanks Bob, and thanks RF. I used seek and tell, and now have the data as part of a module.
Paul On Wed, Feb 05, 2003 at 05:13:24PM -0500, Bob Showalter wrote: > From: Bob Showalter <[EMAIL PROTECTED]> > To: 'Paul Tremblay' <[EMAIL PROTECTED]>, [EMAIL PROTECTED] > Subject: RE: how to set up Makefile.pl > Date: Wed, 5 Feb 2003 17:13:24 -0500 > > Paul Tremblay wrote: > > Thanks, but this won't work. I need to open the data file and read > > some data. Later in the script, I need to open the data file again > > and read more data. When I use <DATA>, perl apparently reads one > > line at a time until it finds what I want. It then starts at the line > > I left off when I need to read more data. It does not start at the > > beginning again, so I cannot find the data I need. > > > > The only solution I can think using the __DATA__ method would be to > > have my script print out *all* data to a temporary file. I could then > > open and close this file when I wanted data. But this seems like kind > > of a hack--and it would take a bit more time, though only a second or > > two. > > Two alternate approaches: > > 1) read the data into a memory structure (array or hash) > > 2) use tell()/seek() on the DATA file handle to move around. > > n.b. seek(DATA, 0, SEEK_SET) does not put you at the first line after > __DATA__, it puts you at the top of your script file. So use tell() to mark > the start point before you start reading. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- ************************ *Paul Tremblay * *[EMAIL PROTECTED]* ************************ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]