use Win32::NetAdmin; my $path = 'c:'; my $file = 'list.txt'; open ( OUT, ">$path/$file" ) || die "Cannot create machine list. :$!"; my @users; Win32::NetAdmin::GetUsers("\\\\PDC",'',\@users); my @computers = grep { /\$$/ } @users; for my $box (@computers) { chop $box; # removes terminal char, must be $ from grep print OUT "$box\n"; # print each $box on a newline } close OUT;