Le mardi 29 mars 2005 � 19:05, David Landgren �crivait:
> > $blah->add_filter(
> > bap => 'eq "zlopp"',
> > clank => '!~ /clunk_eth/',
>
> A hash is unordered. Um hang on, or is this a list of pairs or a hash?
It is a list of pairs. For the moment, the right part is pushed on an
array reference stored in a hash indexed by the left part. So yes, I
can do $blah->add_filter( bap => 'ne "zlopp"', bap => 'ne "klonk"' )
> > chomp;
> > my @data = split qr{:};
> > if( ( $data[1] !~ /clunk_eth/ )
> > && ( $data[0] eq "zlopp" ) )
>
> This is ordered. But in any case, it's not in the same order as above.
Sure, it's a hash.
> I would like to be able to specify order in which the checks are run, so
> as to be able to evaluate the check that fails 99% of the time first.
Good point.
> Also, I'm not sure what to suggest, but...
>
> bap => 'eq "zlopp"',
>
> ...feels icky. I'd rather something that would spit out errors at
> compile time, not at eval time. But I can't think of anything
> approaching that level of tersity. At the very least:
>
> bap => { 'eq' => 'zlopp' }
> clunk => { '~!' => qr/^foom\d+$/ }
> sput => { 'between' => [10, 100] }
>
> Hmm, how do I add a new conditional widget, like 'between' above? e.g. I
> want to extract all HTTP transactions whose lengths are prime fibonacci
> numbers.
Moving away from the inner Perl code is a very good option, which Yves
mentionned as well. My first version simply puts the strings into $code,
which has a lot of red flashing lights all around.
Does your asking this kind of questions mean the module is interesting
enough to be posted on CPAN?
--
Philippe "BooK" Bruhat
When you deal in weapons, there are no winners... only losers.
(Moral from Groo The Wanderer #31 (Epic))