Four very identical regular expressions. I am replacing the strings with the following scalar values. How can this be more efficient?
$line =~ s/\[(receiver)\]/$receiver/g;
$line =~ s/\[(place)\]/$place/g;
$line =~ s/\[(position)\]/$position/g;
$line =~ s/\[(company)\]/$company/g;
Thank you.
Consider just using a real templating system. Template Toolkit for instance is very easy.
Leaving that aside, you say you want it more efficient. Is its current perceived inefficiency a problem? If not, leave it alone.
You could do it all in one pass:
but this will act differently if, for instance,
$receiveris ‘place’.