[Dbix-class] DBIx::Class::HTMLWidget (checkboxes)
    A. Pagaltzis 
    pagaltzis at gmx.de
       
    Fri Jul 14 20:13:19 CEST 2006
    
    
  
* Aaron Crane <dbix-class at aaroncrane.co.uk> [2006-07-14 19:25]:
> A. Pagaltzis writes:
> > So the right way to write that code “fancily” is thus:
> > 
> >     my %cb = map {
> >         $_->isa( 'HTML::Widget::Element::Checkbox' )
> >             ? ( $_->name => undef )
> >             : ()
> >     } @{ $result->{_elements} };
> 
> I think this is much easier to read:
> 
>   my %cb = map  { $_->name => undef }
>            grep { $_->isa('HTML::Widget::Element::Checkbox') }
>            @{ $result->{_elements} };
Good suggestion. Here’s another alternative, just for the peanut
gallery:
    my %cb = map ( $_->name => undef ) x $_->isa( 'HTML::Widget::Element::Checkbox' ), @{ $result->{_elements} };
Regards,
-- 
#Aristotle
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
&Just->another->Perl->hacker;
    
    
More information about the Dbix-class
mailing list