N
neilsolent
Hi
Sorry if this is a basic question.
How can you embed a function inside a replacement operator ?
e.g.:
####################################
sub conv()
{
return $_[0] * 2;
}
$test = 'abc125abc';
$test =~ s/(\d+)/&conv($1)/g;
print $test . '\n';
####################################
The output of this script is:
abc&conv(123)abc
Whereas I would like it to be:
abc250abc
Many thanks,
Neil
Sorry if this is a basic question.
How can you embed a function inside a replacement operator ?
e.g.:
####################################
sub conv()
{
return $_[0] * 2;
}
$test = 'abc125abc';
$test =~ s/(\d+)/&conv($1)/g;
print $test . '\n';
####################################
The output of this script is:
abc&conv(123)abc
Whereas I would like it to be:
abc250abc
Many thanks,
Neil