develooper Front page | perl.beginners | Postings from February 2002

RE: Joining or pushing an element to an array

From:
J.Hourihane
Date:
February 13, 2002 14:46
Subject:
RE: Joining or pushing an element to an array
Message ID:
9877566273EED511A7560008C716DA06B399@exchcpn1.cdcna.com
Overall Goal:
Well what I want to do is print out all the users in the passwd file and
match them up to their respective groups
I can open up the passwd file and the group file but I don't know how to
merge them together.
Ideally I would like to possibly put the group file in a hash but as you can
see my ablity in hashes is limited.

Current Problem:
Trying to join or push an element onto any array

Thanks in Advance 

#############################################
!#/usr/local/bin/perl
$passcmd =  '/usr/bin/ypcat passwd.byname |';
$groupcmd =  '/usr/bin/ypcat group.byname |';

sub pass {
open(PASSWD, $passcmd);
   while(<PASSWD>) {
      ($name,$pass,$uid,$gid,$gcos,$home,$shell) = split(/:+/); 
		print "$uid,$name,$gcos,$home\n";     
   }
 close PASSWD;
}

sub group {
    open(GROUP, $groupcmd);
    while(<GROUP>) {
       ($gname,$gpass,$ggid,$member) = split(/:+/);
	#$HASH{gname} = $member;
    #print "@HASH{`root`}";
	print "$gname";
    }
 close GROUP;
}

sub third {
	&pass;	

}

@passwd = &pass;
@group = &group;
#print @passwd;
$users = join($gname,@passwd);
print "$users\n";

###################################
CDC-IXIS
212.891.1935



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About