Eric Mooshagian wrote:
On Thu, Feb 4, 2010 at 2:24 AM, John W. Krahn <jwkr...@shaw.ca> wrote:

Eric Mooshagian wrote:

I have a few subroutines that I use to first build an index for several
arrays and then, for example, take the mean for the index values.  When I
build the index I can exclude particular values in an array as follows:

my $index = defindex(
   exclude => ["0",\...@accuracy],
   valueof => [...@subject,\...@side,\...@valence],
);


This works fine, but only only for excluding single values like (e.g,
"0").  What I would really like to do is pass an argument that includes
comparators, for example, in pseudo code:

exclude => (responsetime <= 200) && (responsetime >= 1200) where
responsetime refers to an array.

However, I have no idea how to do this using named parameters.  Is there a
strategy for passing such arguments to a subroutine?

Like Perl's built-in sort() function or the File::Find::find() function you
can use a subroutine reference, for example, in pseudo code:

exclude => sub { return something if (responsetime <= 200) && (responsetime
= 1200) }


Thanks! I think this is the clue I've been looking for though I don't yet
understand how to implement the code.  Are dispatch tables relevant here?

Sort of. The principle is basically the same. In your case there is only ever one key that is always the same and it appears that the use of a code reference could be optional.



John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to