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;
####
while () {
my $line = $_;
chomp $line;
# now do something with $line which we got from the file
}
####
@ary = qw(1 2 3 4 5);
print "first ", $ary[0], "\n";
@ary = join("\n",@ary);
print "second", $ary[0], "\n";