[Html-widget] attributes

Carl Franks fireartist at gmail.com
Fri Sep 22 16:28:49 CEST 2006


On 22/09/06, A. Pagaltzis <pagaltzis at gmx.de> wrote:
>
>     my $attributes = sub {
>         my $self = shift;
>         my $attr = $self->attributes;
>         my ( $k, $v );
>         $attr->{ $k } = $v while ( $k, $v ) = splice @_, 0, 2;
>         return $self;
>     };
>
>     $w->element( 'Textfield', 'foo' )
>         ->$attributes( disabled => 'disabled' )
>         ->size( 10 );
>
> Devious regards,

Yes, that is quite devious :)

Maybe not consice enough to document as an idiom, though.
obfu competition time!

my $attributes = sub {
    my ( $self, %attrs ) = @_;
    $self->attributes->{$_} = $attrs{$_} for keys %attrs;
    return $self;
}



More information about the Html-widget mailing list