in reply to Net View Parsing

The problem with your regexp is that since you're matching two backslashes, you need four in the regexp. I've condensed your code a bit; this should work for what you need.
open (PP, "net view |") || die "$!\n"; my @servers = map /^(\\\\[^lw].*?)\W/i, <PP>; close PP || die "$!\n"; open (OUT,">servers.log") || die "$!\n"; print OUT join "\n", @servers; print "List built!\n"; close OUT || die "$!\n";
If you know for sure that net will be installed and working, you could shorten the first three lines to my @servers = map /^(\\\\[^lw].*?)\W/i, `net view`;

Replies are listed 'Best First'.
RE: Net View Parsing
by Robert (Initiate) on May 24, 2000 at 22:33 UTC
    Thanks! Seems like I'm doing something else wrong becouse even fixing the regexp, with the tip you gave me, I can't get the list of servers.
      Well, let's be a bit more diagnostic then. First, what is the format of a line of output from "net view" on your machine? I'm running W2K; you may be seeing different output than I am. Second, try this snippet:
      open (PP, "net view |") || die "$!\n"; print <PP>;
      You should just see the output of 'net view'. If not, try backquotes like I mentioned at the end of my previous post. If that still doesn't work, make sure 'net' is actually in the path as seen by the script. The regexp is pretty generous: all it checks for is two leading backslashes followed by not 'l' or 'w'. Assuming there are computers that match that description, something should get printed. If you're still having troubles, come back with some more details on how it fails.