* Aaron Crane <[EMAIL PROTECTED]> [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;

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to