At lest I like the idea.
Seems like English.
I don't care for the speed(other wise I would use C/C++), running all the
scripts where I work takes some hours and so this will not be a big
overhead.
I didn't think in the "if ($this{big}->[$idx]{thing} in @set) { ... }"
before I sent the e-mail. To this I have to think in function as well. Like
I seed this seems to ease.
For the rest of the answers.
I didn't know "List::Util", but I have something done by myself. Probably
everyone that don't know this module has one.
Now the grep
I use grep some times, but I always have to sink to understands what is
doing if I have a block. So instead of "in ($xxx => "a", 5)" I would have
"grep {($xxx cmp $_) == 0} ("abc", 5)" or "grep {not ($xxx cmp $_)} ("abc",
5)".
Am I the only one with this problem?
The OO approach is out of question. Object are good for simplifying code, in
this case I don't see any simplification.
Marcos
-----Original Message-----
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2003 3:04 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: This seems to ease
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>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>