in reply to variable interpolation sans character interpolation

First thought is the quotemeta function (or \Q \E in the regex). But this won't work if applied multiple times. Consider:
#!/usr/bin/perl use strict; use warnings; my $string = '\.foo'; print $string, "\n"; for (1..3) { $string = quotemeta $string; print $string, "\n"; } __END__ # prints: \.foo \\\.foo \\\\\\\.foo \\\\\\\\\\\\\\\.foo
But if you're just concatenating, you can do something like:
#!/usr/bin/perl use strict; use warnings; my $string = '\.foo'; print $string, "\n"; for (1..3) { # Note the concatenation instead of re-quotemeta-ing $string .= quotemeta "*[$_]"; print $string, "\n"; } __END__ # prints: \.foo \.foo\*\[1\] \.foo\*\[1\]\*\[2\] \.foo\*\[1\]\*\[2\]\*\[3\]
This help? If not, perhaps some code examples would be beneficial.