[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [Fun With Perl] Package Retrofit



>From vlb@cfcl.com  Fri Jun 11 12:25:18 1999 - apologies for the delay - vlb]
Message-Id: <v04020a15b38709a40689@[192.168.0.77]>
In-Reply-To: <3761573B.9AC60E30@netscape.com>
References: <v04020a01b386a6a9a617@[192.168.0.77]>
Date: Fri, 11 Jun 1999 14:48:59 -0400
To: John Kristian <kristian@netscape.com>
Cc: fwp@technofile.org

At 14.36 -0400 1999.06.11, John Kristian wrote:
>Chris Nandor wrote:
>
>>     if (not can Mozilla::LDAP::Entry 'getLDIFrecords') {
>>         *Mozilla::LDAP::Entry::getLDIFrecords = sub {
>>             [snip]
>>         };
>>     }
>>
>> It does the same thing, but avoids the eval.  You don't need a separate
>> package declaration, you can just put it in the sub declaration.
>
>Huh?  Would you give an example, please?  Or did you mean to say I don't need
>any package declaration at all (as in the example above)?

You do not need a package declaration.  You can use "sub
Package::Foo::Bar::Sub" to create a sub Sub() in package Package::Foo::Bar.

Of course, since we don't want the sub to be created unless it meets the
criteria in the expression above, we can't use "sub foo {}".  Our choices
are to eval it, or to assign a coderef to a typeglob.  Some people prefer
evals, wanting to avoid typeglobs whenever possible.  I prefer to avoid
evals whenever possible.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

==== Want to unsubscribe from this list? (Don't you love us anymore?)
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org

</x-flowed>