Appreciate your concerns but the code is still not doing what I expect it to do. I am only getting the groups name out and not the users. Can someone explain the code for me or rather send me a snippet that is readable for my level? After this forum is for the beginners, right.
File 1 spp/users spp/users iam/users spp/817208 iam/817208 File2 user group group group group groupn zions/pwitthoeft spp/users iam/users spp/817208 > iam/817208 zions/vduarte lpaccess/users exclist/users zions_dsandoval exclist/users epn/users lpcom/users "Jose Nyimi" <[EMAIL PROTECTED]> 08/18/2004 03:47 PM To: "'Gunnar Hjalmarsson'" <[EMAIL PROTECTED]>, [EMAIL PROTECTED] cc: Subject: RE : Data comparision analysis > -----Message d'origine----- > De : Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] > Envoyé : mercredi 18 août 2004 17:18 > À : [EMAIL PROTECTED] > Objet : Re: Data comparision analysis > > Marcos Rebelo wrote: > > Gunnar Hjalmarsson wrote: > >> Or a little shorter: > >> > >> #!/usr/bin/perl > >> use strict; > >> use warnings; > >> open my $GROUPS, 'File1' or die $!; > >> open my $USERS, 'File2' or die $!; > >> > >> my %groups; > >> chomp and $groups{$_} = [] for <$GROUPS>; > >> > >> while ( <$USERS> ) { > >> my ($user, @groups) = split; > >> $groups{$_} and push @{ $groups{$_} }, $user for @groups; > >> } > >> > >> for ( sort keys %groups ) { > >> print "$_:\n", ( join "\n", @{ $groups{$_} } ), "\n\n"; > >> } > >> > >> __END__ > > > > It seems to me that Olakunle Banjo shall not be an Perl Expert. > > What's your point? Are you assuming he is here for some other reason > but learning Perl? > > > Can you also explain him the code? > > If there is anything specific in the code that you, Olakunle or > somebody else do not understand by help of the Perl docs, I'll be > happy to explain. > > > Note: Usually is good policy closeing the opened files. > > If I have understood it correctly (please correct me if I'm wrong), > when you use a my() declared filehandle reference, closing is done > automatically when you go out of scope (in this case: when the script > exits), and since I'm not interested in possible error messages, I'm > not aware of any good reason for closing the filehandles explicitly. > Gunnar, your code is clean, powerfull and maintainable ... I wouldn't write it in an other way even though TIMTOWTDI :-) It's not good pratice avoid using perl's flexibility and write "bad" code just to make your code "understandable" to non perl experts. In contrary use good perl's features that will allow non experts to learn from you. Just my opinion. José. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>