On Wed, 16 Oct 2002, George C Mccone wrote:

>
> When defining the methods to export, use the %EXPORT_TAGS instead of the
> @EXPORT
>
> %EXPORT_TAGS = ( ALL => [ method1, method2, MyFoo] , SOME => [ method1] );
>
> Then use the module as follows for none OO
>
> use MyStuff qw(:ALL);
> $foo = MyFoo();
>
>
> For OO Implementation
>
> use MyStuff; # nothing exported
> $foo = new MySuff();
> $foo->MyFoo();

But that doesn't take into account that when accessing object methods
(as opposed to Exported functions), the method automagically receives an
object reference as its first parameter.

However, it appears that I can simplify the package stucture by just
adding a special tag to my @EXPORT_OK list, then checking for its
existence in the import function and setting my $mode variable. Then the
methods can check $mode as before to determine whether they need to
shift the extra parameter out of the argument list.

Or better yet, I can just set $mode in my new() method.

The main advantage to my original approach is that it allows the use of
@EXPORT to automatically export some default functions. The other
methods require the use of a symbol list in the 'use Packagename' call
to determine what to export.

-- 
Ernest MacDougal Campbell III, MCP+I, MCSE <[EMAIL PROTECTED]>
      http://dougal.gunters.org/ http://spam.gunters.org/
  Web Design & Development:  http://www.mentalcollective.com/
       This message is guaranteed to be 100% eror frea!

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to