> 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?
If you change my $rvar = "\$interface"; To my $rvar = '\$interface'; It works like I think you want it to. The reason it wasn't working before is because the regex was seeing: $cmd =~ s/$interface/test/; Because when you declared $rvar, it saved the string '$interface', which then got interpolated by the regular expression. HTH, -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]