You don't need the 'x' option (white space used in RE for comments) or the 
'o' option (compile it - this is used when there is a variable in the RE, 
e.g.
$name = "Name:"
while (<>) {
   if ( /$name/o ) {

the colon (":") is not a special char and does not need an escape slash.

The '1' you get now is the number of matches, you need to have caputuring 
parens to get a return here:
($name) = $out =~ m/Name\:/xo ;
($name) = $out =~ /Name:\s+(.*)/;

A standard way to do this:
open(CMD,"c:/tmp/test.cmd /i $c |")
   or die "can't run cmd: $!"
while (<CMD>) {
   if ( /Computer Name:/ ) {
      print;
   } elsif ( /User Name:/ ) {
      print;
   }
}   # while <CMD>
close CMD;

Note, now that you have this processing it line by line, you can do:
   if ( /Computer Name:\s+(.*)/ {
       my $computer = $1;
       print "The computer is called $computer\n";
   }

That is, you can capture and work w/ the data in your script before 
outputting it.



Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED] 
VOICE: (608) 261-5738  FAX 264-5030

" ... even if you're mediocre/decent at perl [the cmecf] code is pretty 
confusing in certain areas ..." CB
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to