> OK! > > my script works! But when I use: > > my $rvar = <STDIN>; > > I have the same problem! Jesus, that's a hard one :-)
After you read it in, do you have a '$' in the string? If so, you need to escape it like so: $rvar =~ s/\$/\\\$/g; That should fix the problem. If it doesn't, could you paste more of the code you're using? -dave > >>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] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]