yes, absolutely, use the code if it is useful.
code to read file:
# deal with absence of pwfile.
unless ( -e $passwd ) {
# PANIC, quit, etc.
die("No passwd file found");
}
# open file handle for read
open(PASSWD, $passwd) or die("Cannot open passwd file for read.");
# push each entry into an array
while (<PASSWD>) {
# remove the trailing \n
chomp $_;
# add line to array
push (@pwfile, $_);
}
#close the file handle.
close(PASSWD);
then all your data is stored in @pwfile. |