parametrical substitution in perl
- From: "ari" <unikoski@xxxxxxxxx>
- Date: 31 Oct 2005 09:24:11 -0800
I want to write a subroutine which performs string substitution
parametrically, as follows:
sub doit()
{
my ($in,$before,$after)=@_;
my $out;
$out = $in;
$out =~ s/$before/$after/e;
return $out;
}
In general this works fine, but if I try and use captured buffers, it
doesn't work. For example, I want to do the following:
s/^(...)/$1 /
i.e. insert a blank after the first three chars.
if I do:
&doit("ABCDEF","^(...)",'$1 ');
I get back "$1 DEF"
Does anyone know how to make this work???
.
- Prev by Date: Re: sleep between system calls
- Next by Date: Re: using perl to print yesterday's date, but with formatting options ?
- Previous by thread: Re: sleep between system calls
- Next by thread: Re: using perl to print yesterday's date, but with formatting options ?
- Index(es):