[Mpls-pm] Dumb Question...Module Method - Dual Name

Ken Williams ken at mathforum.org
Thu Oct 20 14:34:30 PDT 2005


On Oct 20, 2005, at 3:18 PM, Gary Vollink wrote:

> O.K., this is for you folks who do modules...
>
> If I have a Module that default exports:
> @EXPORT = qw/corvuDbSelect corvuDbRun corvuDbFetch/;
>
> But say, in a more sane OO land, I would want corvuDb dropped...
>
> -----
> require corvu::Db;
>
> $mydb = corvu::Db::new();
>
> $mydb->Select($sql);
> $mydb->Fetch($sql);
> -----

Yeah, your idea is essentially right.  You'll need to use ->new() 
instead of ::new(), though.  And if you want to preserve the old 
corvuDbSelect() method, you should implement it like so, because 
Select() is now a method, not a function:

   sub corvuDbSelect {
     __PACKAGE__->new()->Select( @_ );
   }

  -Ken



More information about the Mpls-pm mailing list