And to use it...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';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RFC: Text::Grap
by betterworld (Curate) on Jul 12, 2006 at 21:38 UTC | |
|
Re: RFC: Text::Grap
by adrianh (Chancellor) on Jul 13, 2006 at 07:06 UTC | |
|
Re: RFC: Text::Grap
by kwaping (Priest) on Jul 13, 2006 at 15:14 UTC | |
|
Re: RFC: Text::Grap
by duff (Parson) on Jul 13, 2006 at 03:23 UTC | |
|
Re: RFC: Text::Grap
by VSarkiss (Monsignor) on Jul 13, 2006 at 14:19 UTC | |
|
Re: RFC: Text::Grap
by Ieronim (Friar) on Jul 13, 2006 at 12:31 UTC | |
by Tanktalus (Canon) on Jul 13, 2006 at 14:04 UTC | |
by Ieronim (Friar) on Jul 13, 2006 at 17:54 UTC | |
by Ieronim (Friar) on Jul 13, 2006 at 17:36 UTC | |
|
Re: RFC: Text::Grap
by radiantmatrix (Parson) on Jul 20, 2006 at 19:30 UTC |