[Israel.pm] bless and AUTOLOAD

Yona Shlomo yona at cs.technion.ac.il
Tue Sep 25 21:22:51 PDT 2007


On Tue, 25 Sep 2007, Yuval Yaari wrote:

> Yona Shlomo wrote:
>> Is well in place, but alas, I'm too lazy to implement
>> several dozens of functions/methods that are the same except
>> for their name... and then change (all of them with no
>> mistakes) then when needed...
>>
> How about...
>
> <UGLY>
> BEGIN {
>    no strict 'refs';
>    *{__PACKAGE__ . '::' . $_} = sub {}
>            for qw/foo bar baz DESTROY/;
> }
> </UGLY>

Way cool!! :-)
This actually defines the subs automatically in the BEGIN
block.

Now the question is what is more ugly: to use AUTOLOAD or to
use this.

-- 
Shlomo Yona
yona at cs.technion.ac.il
http://yeda.cs.technion.ac.il/~yona/



More information about the Perl mailing list