SPUG: interpolating into a string variable

Fred Morris m3047 at inwa.net
Sat Dec 20 23:50:43 CST 2003


Let's say we have a string variable. In practice it's read in from a file,
but it could be a constant. And what we want to do is force interpolation
into it before we use it for something like... ooooh, a regex. So,
something like this:


    my $foo_str = 'foo';

    my $expr = 'a $foo_str happens here';

    my $interpolated_expr = something magic happens to $expr;

and then if you print "$interpolated_expr\n"; you would get

    a foo happens here


Is there a way to do this? For some reason, I thought there was... thought
I'd ask, because it's a Saturday night and the answer isn't materializing
for me... dang.

--

Fred Morris
fredm3047 at inwa.net (I-ACK)





More information about the spug-list mailing list