Wim De Hul wrote: > > Hey folks, > > I'm writen a script to manage my router configuration. > To get the IOS version I use regular expressions. > First, I did it with: > > $_ = &getparameter($sysdescr_mib,"System description"); # Get > the SysDescr via SNMP > /Version /; > $_ = $'; > (/, /); > $swversion = $`; > > But this is not the way I want it to do... I like to have more > "professional" code. > Is there a way to do it in one line (probably there is)? > > I tried with: > > $_ = &snmpget($sysdescr); > $IOS_version = /Version (.*?)\, /i; > > When I do now: print "$1\n"; I get the IOS version > But when I type print "$IOS_version\n"; It displays just 1... > Can I get rid of the S_?
A matching always return a list of the captured items. On the left side of the assignment is a scalar, so list in a scalar context returns its size. To avoid it, simple put your variable in brackets: ($IOS_version) = /Version (.*?)\, /i; Best Wishes, Andrea -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]