An update on previous post...
It seems that I typed some errors :-(
This is a small rewrite of my script...
#!/usr/bin/perl
use warnings;
my $var = "test";
my $rvar = "\$interface";
my $cmd = "int \$interface\n";
print "$var\n";
print "$cmd\n";
$cmd =~ s/$rvar/$var/g;
print "$cmd\n";
If you run this, the $interface in the variable $cmd isn't replaced by
test...
Why?
Greetz, and thanks for the great help!
Wim
David Gray wrote:
>>I have a problem with substitutions...
>>In the piece of code, here below,
>>"display $var1, $var"' should be "display val1, val2";
>>I don't see why, but the if condition doesn't seems to
>>work... and if I remove the if condition, the replacement
>>doesn't occur... Does any of you know why?
>>
>>$VarValue{$var1} = "val1";
>>$VarValue{$var2} = "val2"
>>$Cmd = "display $var1, $var2";
>>
>
>The previous line evaluates to 'display , ' when the perl interpreter
>hits it because it looks for the variables $var1 and $var2, but can't
>find them, so it uses '' (the string value of undef) instead. You might
>want to try:
>
>$Cmd = 'display $var1, $var2';
>
>Same thing for the hash you're creating... If you want to do what I
>think you want to do, you need to define that hash as:
>
>$VarValue{'$var1'} = 'val1';
>$VarValue{'$var2'} = 'val2';
>
>HTH,
>
> -dave
>
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]