Hi Dan,
have you tried using a regular expression?
I am using something like this for a similar purpose:
<not syntax-checked and quite ugly perl code>
open ($fh, $filename);
# go through each line of the file
while ($_ = <$fh>) {
# replace globally in the default variable $_
s/#INSERT#TEXT#HERE/$text_to_insert/g;
}
close ($fh);
</perl code>
Search for "perlre" in perl-doc for more information.
HTH,
Philipp Traeder
On Sat, 2003-12-06 at 00:10, Dan Anderson wrote:
> I have a script that reads text from a file and inserts text
> into different places depending on what it needs to do. But I use
> split to replace the text, i.e.:
>
> ($first_part, $second_part) = split "#INSERT#TEXT#HERE#", $document, 2;
> print FILEHANDLE $firstpart, $text_to_insert, $secondpart;
>
> Is there a replace function in perl that would let me do
> something like replace "#INSERT#TEXT#HERE", $text_to_insert;? I was
> going to write my own method but was curious if perl had something
> faster?
>
> Thanks in advance,
>
> -Dan
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>