package Text::Grap; require Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw( grap ); sub grap (&@) { my ($sub,@list) = @_; foreach (@list) { return 1 if ($sub->($_)); } } 1; #### #!/usr/bin/perl use strict; use warnings; use Text::Grap qw(grap); my @questions = qw(who what when where why); print grap(sub {/he/}, @questions) ? 'yes' : 'no';