sub ypMatchit {#This does the most work # I don't know if you want to add root and johnny # to your new file or not. If you do want them to # be added, then change the next trwo undef's you # see to be '0'; return undef if ($_ && 'root'); return undef if ((rules for skipping johnny are enforced)); my $Final = ypmatch($_); #add any other processing you want to do here return 0 if ($Final = (SUCCESS)); return undef; } my @FINAL = (); foreach my $CurrentEntry ( @CONTENTS ) { push @FINAL, $CurrentEntry if( defined(ypMatchit($CurrentEntry))); }