Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my $file = "myfile"; open(FILE,$file); foreach (<FILE>) { $_ =~ s/\<REPLACE_TEXT_1\>/&replace_text_1/ if $_ =~ m/\<REPLACE_T +EXT_1\>/; print "$_"; } close(FILE); sub replace_text_1 { #some stuff print "foobar"; #some other stuff }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: replacing text with a function
by gjb (Vicar) on Jan 14, 2003 at 13:26 UTC | |
by Anonymous Monk on Jan 14, 2003 at 13:41 UTC | |
|
Re: replacing text with a function
by AcidHawk (Vicar) on Jan 14, 2003 at 13:32 UTC | |
|
Re: replacing text with a function
by pfaut (Priest) on Jan 14, 2003 at 13:31 UTC | |
|
Re: replacing text with a function
by vek (Prior) on Jan 14, 2003 at 13:45 UTC | |
|
Re: replacing text with a function
by dash2 (Hermit) on Jan 14, 2003 at 14:59 UTC |