Thank you so much for this, Jenda and Daniel and Adam

Could you give me a stab of code demonstrating appending or printing a
record (like the one below) to a
scalar (or pushing to an array) and how I might avoid printing OUT but
retain the changes I
made to the filehandle so they can be passed to another loop. Memory
shouldn't be an issue.

Regards,

Richard 

-----Original Message-----
From: Daniel Staal [mailto:[EMAIL PROTECTED] 
Sent: 13 April 2004 16:32
To: Perl Beginners
Subject: Re: Avoiding using temporary files

--As of Tuesday, April 13, 2004 2:16 PM +0200, Jenda Krynicky is alleged
to have said:

>> I am running some substitutions on a file which has a distinctive 
>> record structure. Each record is printed to the output filehandle in 
>> turn after the substitutions have been performed. Once all records 
>> are printed out I need to go back over them i.e. go back to the top 
>> and do some further work on the OUT filehandle.
>
> If you can change the code it might be best not to print them at all.

--As for the rest, it is mine.

Another option, if the above has problems for you, is to print them to a
variable: Perl 5.8 can open a scalar as a filehandle.  Do your writing,
the close the filehandle and use the scalar directly.

Not printing at all would be best though, if the code can afford it.

That is, if can afford to hold the whole file in memory...  (Which both
of these do.)

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you are
expressly allowed to retransmit, quote, or otherwise use the contents
for non-commercial purposes.  This copyright will expire 5 years after
the author's death, or in 30 years, whichever is longer, unless such a
period is in excess of local copyright law.
---------------------------------------------------------------




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