in reply to What's the best way to convert a non interpolated single-quoted string into an interpolated double-quoted string?

I that situation I use place holder text that is replaced at run time using a regex and a hash lookup. Something like the following:

my %subs = (home => 'HomePathFromConfigOrEnv'); my $keyMatch = join '|', keys %subs; my $cfgStr = '!home!/path'; $cfgStr =~ s/!($keyMatch)!/$subs{$1}/g; print $cfgStr;

Prints:

HomePathFromConfigOrEnv/path
True laziness is hard work
  • Comment on Re: What's the best way to convert a non interpolated single-quoted string into an interpolated double-quoted string?
  • Select or Download Code