> -----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>


Reply via email to