[Catalyst] Catalyst::component()

Bernhard Graf catalyst at augensalat.de
Tue Oct 4 18:00:33 CEST 2005


Wade.Stuart at fallon.com wrote:
> To clarify what I mean about $c->comp...
>
> sub component {
>     my $c = shift;
>
>     if (@_) {
>
>         my $name = shift;
>
>         if ( my $component = $c->components->{$name} ) {
>             return $component;
>         }
>
>         else {
>             for my $component ( keys %{ $c->components } ) {
>                 return $c->components->{$component} if $component =~
> /$name/i;
>             }
>         }
>     }
>
>     return sort keys %{ $c->components };
> }
>
> Is the current code,  If I send a string that you think should match
> exactly but does not,  I get back a what appears to be random
> component that hits the regex in some cases.  In my mind,it should

It is worse if you read my mail
http://lists.rawmode.org/pipermail/catalyst/2005-August/001464.html

> work such that if I send a string to it, and have no exact matches --
> send back a fail.  If I want a regex match I should be able to
> explicitly send the regex and get a regex match or fail.  The bottom
> (fall through) case is still acceptable in my mind -- no @_ = default
> of list all components.

I like the idea with the compiled regex (qr) too.
-- 
Bernhard Graf



More information about the Catalyst mailing list