On Dec 8, [EMAIL PROTECTED] said:
>I did the 'in' function for seeing if one element is inside on list like.
Well, although it's overkill, Quantum::Superpositions has a 'any' function
that can be used like so:
if ($x == any(1, 4, 9, 16)) { ... }
But Q::SP is a really big module, and won't work as efficiently as it
theoretically should.
>sub in {
> my $match = shift;
> foreach (@_) {
> return 1 if $match eq $_;
> }
> return 0;
>}
That's a very succinct function, and probably the best way to write it.
>package MyFilter;
>use Filter::Simple;
>use vars qw (@ISA @EXPORT @EXPORT_OK);
>
>require Exporter;
>push(@ISA, qw(Exporter));
>@EXPORT_OK = qw(in);
>
>FILTER_ONLY code => sub {
> my $ph = $Filter::Simple::placeholder;
> s/(((\$[a-zA-Z_0-9]+)|\-?[0-9]+(\.[0-9]+)?|$ph))\sin\s/in $1, /g;
> };
>This seems to work.
>Can someone test some more and give some bugs?
>Is there a generic module for doing operators?
I've never used Filter::Simple, so I don't know what $ph is representing,
so I'd like to know if your module can handle
if ($this{big}->[$idx]{thing} in @set) { ... }
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>