KYu wrote:
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
always
use strict; use warnings;
$var1 = "one"; $str = "number $var1, "; print $str;
$var1 = "two"; print $str;
You never changed the value of $str. You need:
my $var1 = 'one'; my $str = "number $var1, "; print $str;
$var1 = "two"; $str = "number $var1, "; print $str;
or you could use a function to do it sort of like you're wantign, like so:
my $str; set_str(\$str,'one'); print $str;
set_str(\$str,'two'); print $str;
sub set_str { my ($ref,$var) = @_; ${$ref} = "number $var, " if ref($ref) eq 'SCALAR'; }
or maybe constants are what you are looking for, havn't used them too much myself but I'm sure perldoc has something good about them.
produce "number one, number one" to the output. But what I must to do, that output would be "number one, number two" ??
Best regards, KYu
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>