#!/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 }
In reply to replacing text with a function by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |