Re: Searching ahead in a file

2004-07-09 Thread perl.org
> From: ml-perl[at]thepierianspring.org (Randy W. Sims) > > Once > your program allocates memory, it can never be freed even if you > undefine every variable in your script. Will that memory be re-used by the existing Perl process, or is it just leaked? "Terrorism is a symptom, not the diseas

Re: Searching ahead in a file

2004-06-30 Thread Randy W. Sims
On 6/30/2004 4:38 PM, perl.org wrote: If the file is relatively small, why not read it into an array, then just manipulate the array index? Something like: my @{lines} = ; Small pet peeve: slurping entire files is a bad habbit in general. Once your program allocates memory, it can never be freed

Re: Searching ahead in a file

2004-06-30 Thread DBSMITH
AIL PROTECTED]> 06/30/2004 05:52 PM To: [EMAIL PROTECTED] cc: [EMAIL PROTECTED] Subject: Re: Searching ahead in a file Japhy et al, This worked perfectly for what I want to do. Thanks to all of you, I am learning at a greater rate than by working

Re: Searching ahead in a file

2004-06-30 Thread David Arnold
Japhy et al, This worked perfectly for what I want to do. Thanks to all of you, I am learning at a greater rate than by working alone. Many thanks. At 04:32 PM 6/30/04 -0400, Jeff 'japhy' Pinyan wrote: >On Jun 30, David Arnold said: > >>As I begin reading in lines from the file, I just print t

Re: Searching ahead in a file

2004-06-30 Thread perl.org
Sorry, while( ${ln} <= $#lines ) That $# starting with -1 thing really gets to me. On Wed, 30 Jun 2004 16:38:45 -0400, perl.org wrote > If the file is relatively small, why not read it into an array, then > just manipulate the array index? Something like: > > my @{lines} = ; > close( IN ); >

Re: Searching ahead in a file

2004-06-30 Thread perl.org
If the file is relatively small, why not read it into an array, then just manipulate the array index? Something like: my @{lines} = ; close( IN ); my ${ln} = 0; while( ${ln} <= $#lines + 1 ) { # check ${lines[${ln}]} and manipulate ${ln} accordingly. } > I would suggest the following approach:

Re: Searching ahead in a file

2004-06-30 Thread Jeff 'japhy' Pinyan
On Jun 30, David Arnold said: >As I begin reading in lines from the file, I just print them until I hit a >line that has an opening "\ex" in it. At that point I want to accumulate >lines in one long string until I hit either "\begin{instructions}" or >another "\ex". > >$line.= #unless the curren

Searching ahead in a file

2004-06-30 Thread David Arnold
All, I have a file that is filled with exercises that was written in a brand of lamstex that I need to convert to latex. Exercises begin like this: \ex If $f(x)=x^2$, blah ... That is, I can count on each exercise beginning with the \ex macro. Now there are at times instructions for groups of e