#!D:\Perl\bin -w use strict; use Win32::NetAdmin; open (OUT,">list.txt") || die "Cannot create machine list. :$!"; # This will get the list of machine names from the PDC my @users; Win32::NetAdmin::GetUsers("\\\\Weasel",'',\@users); my @computers = grep { /\$$/ } @users; foreach my $box (@computers) { chop $box; # removes terminal char, must be $ from grep print OUT "$box\n"; # print each $box on a newline } close OUT; #### # this will take a file and read it in and resolve hostname # to ip address ##################################################################### print "What file do you want to read?"; chomp($InFile = ); open(IN,$InFile) || die "Cannot open $InFile: $!"; open(OUT,">results.txt") || die "Cannot create results.txt: $!"; while () { my $hostname = $_; chomp $hostname; @addr = gethostbyname($hostname); # note: an array now splice(@addr, 0, 4); # get rid of other stuff foreach (@addr) { print OUT join('.', unpack('C4', $_)) ."\t" . $hostname . "\n"; } } close(IN); close(OUT);