Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

CPAN Module Naming Suggestions.

by shotgunefx (Parson)
on Mar 04, 2002 at 09:20 UTC ( #149084=perlquestion: print w/replies, xml ) Need Help??
shotgunefx has asked for the wisdom of the Perl Monks concerning the following question:

I've recently registered at CPAN and was wondering if I could get some feedback on what would be the appropriate namespace to place my first contribution. I mailed modules(at) but haven't heard anything yet.

The module contains a grep-like function findone for finding elements in @arrays.
my @giant_array = (defined elsewhere); while ( my $pid = findone{ matches_criteria($_) } @giant_array){ # Do something with element found. }
I was thinking since this needs an actual array (or something that looks like an array), that this would probably fit best under the ARRAY namespace.

Any thoughts or suggestions would be most welcome.


"To be civilized is to deny one's nature."

Replies are listed 'Best First'.
Re: CPAN Module Naming Suggestions.
by broquaint (Abbot) on Mar 04, 2002 at 13:02 UTC
    How about Array::FindOne, or Array::FindFirst, or if you're feeling verbose and in a trend-setting mood Array::Find::One. Personally I'd go with Array::FindOne, but think that Array::FindFirst may convey a more accurate idea of the module's purpose.


      Thanks for the suggestion. I was thinking Array::Findone myeself.

      While there is a findfirst function, the difference is findone knows where it is within an array, so on subsequent calls it gives subsequent elements. "sort-of" like a closure without the closure. Basically it knows from the source code context what array you are using.

      # It's does something similar to this. sub elementer(&\@;$$) { my ($coderef,$arrayref,$start_index,$end_index) = @_; $start_index = 0 unless $start_index; $end_index = $#{$arrayref} unless $end_index; return sub { return if $start_index > $end_index; for (; $start_index <= $end_index;$start_index++){ $_ = $arrayref->[$start_index]; if (&$coderef){ $start_index++; return wantarray ? ($_ ,($start_index -1 ) ) : $_ +; } } } } my @nums = (1..1000); my $find = elementer { "$_" =~m/5$/ } @nums ; while (my $found = $find->() ) { # ... do something with each match print $found,"\n"; }


      "To be civilized is to deny one's nature."
        Hmmmm, maybe it's name should note it's iterating ability, such as Array::Iterate::Conditional or Array::Iterate::Search. I think they would give a clearer idea of what the module will do.


      or if you're feeling verbose and in a trend-setting mood Array::Find::One.

      For what it's worth, a few months ago, there was a discussion on the Date-Time mailing list, in which a few people disapproved of 3-level module names. I do not understand why, but if you encounter those people, maybe you'll have to stick with (for example) Array::FindOne.

        Thanks. I like Array::FindOne myself but I don't neccassarily think like other people. I prefer two levels unless there is a semantic reason like Net::Service::SomeService. Thanks for the feedback.


        "To be civilized is to deny one's nature."
Re: CPAN Module Naming Suggestions.
by dash2 (Hermit) on Mar 04, 2002 at 13:24 UTC
    The problem you have written the solution to is 'how do I grep an array one at a time, without going through the whole array'... how about Array::LazyGrep or Array::LazyFind?

    dave hj~

      Thanks for the suggestion. I'm kind of stuck on the findone part of the name.
      (I should have been more clear in my original post. I was thinking more of the toplevel namespace.)
      While it may sound stubborn, but the whole purpose of making this construct (for me) was it was in a proprietary LISP'ish' type language that I used to use and I missed it. (About the only thing I did miss.) The construct just fits the way I think logic.


      "To be civilized is to deny one's nature."
        Why don't we just add this functionality to Set::Scalar or Set::Array? :)
Re: CPAN Module Naming Suggestions.
by rjray (Chaplain) on Mar 04, 2002 at 22:50 UTC

    Since the module provides both findone and findfirst, why not simply call it Array::Find?


      I liked Array::FindOne myself but Array::Find I think is clearer to the modules intent.


      "To be civilized is to deny one's nature."

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://149084]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2018-06-21 20:56 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (119 votes). Check out past polls.