This works for me because I can then validate what is returned from the function by checking what is in $rep.
-----#!/usr/bin/perl -w use strict; my $file = "myfile"; open(FILE,$file); my $rep = &replace_text_1; foreach (<FILE>) { $_ =~ s/\<REPLACE_TEXT_1\>/$rep/ if $_ =~ m/\<REPLACE_TEXT_1\>/; print "$_"; } close(FILE); sub replace_text_1 { #some stuff #print "foobar"; #some other stuff return("foobar"); }
In reply to Re: replacing text with a function
by AcidHawk
in thread replacing text with a function
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |