> Hello,
> I was confront  with a such question: how to define the strings, which
> should be interpolated every time when it met?
> 
> For example, this code
> 
> $var1 = "one";
> $str = "number $var1, ";

Right here Perl interpolates $var1 and stores the complete value into
$str, which is set.  Essentially you are looking for an expanded use of
interpolation rules based on using $var1 as if it was a reference of
some type (I suppose a module/pragma might actually exist for this but I
haven't seen it).

> print $str;
> 
> $var1 = "two";
> print $str;
> 
> produce "number one,  number one" to the output. But what I must to
do, that
> output would be
> "number one, number two" ??
> 

In general you have to continually modify $str, for instance,

my $str = "number $var1";
print $str;

$str .= ", number $var1";
print $str;

Obviously you could set your constant value into a separate variable so
that you could change them all quickly if you want.

HTH,

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to