Andrea Holstein wrote: > > Wim De Hul wrote: > > > > 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. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ While this is true that is _not_ what is happening in this case.
$ perl -le'$data = "one two three four five six"; $test = $data =~ /(\S+)\s+(\S+)\s+(\S+)/; print "Test 1: $test"; ($test) = $data =~ /(\S+)\s+(\S+)\s+(\S+)/; print "Test 2: $test"; $test = $data =~ /(\S+)\s+(\S+)\s+(\S+)/g; print "Test 3: $test"; ($test) = $data =~ /(\S+)\s+(\S+)\s+(\S+)/g; print "Test 4: $test"; $test = () = $data =~ /(\S+)\s+(\S+)\s+(\S+)/; print "Test 5: $test"; ' Test 1: 1 Test 2: one Test 3: 1 Test 4: four Test 5: 3 perldoc perlop [snip] m/PATTERN/cgimosx /PATTERN/cgimosx Searches a string for a pattern match, and in scalar context returns true if it succeeds, false if it fails. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]