> OK!
>
> my script works! But when I use:
>
> my $rvar = ;
>
> 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
On Friday, April 12, 2002, at 04:59 , Wim wrote:
> OK!
>
> my script works! But when I use:
>
> my $rvar = ;
>
> I have the same problem! Jesus, that's a hard one :-)
are you expecting a single line of input to come at you?
if not why not 'nest' it in a line read cycle
while() {
OK!
my script works! But when I use:
my $rvar = ;
I have the same problem! Jesus, that's a hard one :-)
Greetz...
David Gray wrote:
>>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;
>>
>>
> 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/$rva
On Thursday, April 11, 2002, at 10:57 AM, wim wrote:
> my $var = "test";
> my $rvar = "\$interface";
>
try:
my $rvar = '\$interface';
so it doesn't look like a variable to be interpolated when you get to the
substitution.
> my $cmd = "int \$interface\n";
>
> print "$var\n";
> print "$cmd\
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 y
> 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?
Wim,
Sorry, I forgot to mention escaping/single quoting the hash keys too...
As you defined it, your hash is empty as you are trying to set 'val1', 'val2' to
VarValue{undef} ($Var1 hasn't been defined).
Try
VarValue{'$Var1'}
or
VarValue{"\$Var1"}
Now the string '$Val1' is a the key, not undef.
Wim,
I can't believe how long it's taken me to figure out what you're on about, and what
the problem (probably) is. My brain's far too slow to be at work today :)
If cmd came from standard input or something, your script would work. But you're using
a string to simulate that input, and because
Tristan,
I'm writing a script to send command from a textfile to cisco devices...
I the textfile, I like to have variables, something like
conf t
int $interface
.
when my script reads the line, it should replace $interface by the value
asked from the value the user enters...
$var{$interfa
Wim,
You're not declaring $var1 or $var2 anywhere. Instead you're assigning 'val1' and
'val2' to elements in the hash %VarValue.
So something like...
$VarValue{$var1} = 'val1';
print "I like $VarValue{$var1}!";
will print out...
I like val1
To define $var1, do something like:
$var1 = 'cheese'
Hello people from the mighty list,
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
12 matches
Mail list logo