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{$interface} contains that value... in the previous mail, $var has nothing to do with perl ;-) Sorry, I wasn't clear (in my head ;-) ) [EMAIL PROTECTED] wrote: >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'; > >Now $var1 is 'cheese', and $VarValue{$var1} is the value of %VarValue with a key of >'cheese'. > >My head hurts! > >Tristan > > >p.s. What are you trying to do? I.e. what's that code for? It looks like a mighty >confusing way of doing anything. Replacing a hash key with it's hash value seems like >a bad idea to me. > > >You Wrote: >---------- > >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 any of you know why? > >$VarValue{$var1} = "val1"; >$VarValue{$var2} = "val2" >$Cmd = "display $var1, $var2"; > >foreach $Tmp ( sort keys %VarValue ) { > if ( $Cmd =~ /$Tmp/ ) { > print "***** In command $Cmd, replace $Tmp by $VarValue{$Tmp}\n"; > $Cmd =~ s/$Tmp/$VarValue{$Tmp}/g; > } >} > > > >Thanx a lot! > >Wim > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]