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

Re: [cgiapp] Creating a Plugin module


On 2/15/06, Paul Johnston <suppressed> wrote:
> As an example, say that the application is a blogging application, and I
> want to create the variable:
>
> $self->blog
>
> so that I can do
>
> $self->blog->getBlog($blogid);
>
> (or some such equivalent method) that returns (say) a database handle.
>
> How would you do this by putting *just*
>
> use MyApp::Plugin::Blog;
>
> at the top?
>
> I'm confused.  Am I missing something about cgiapp that I should know about?

All you need to do is export a 'blog' method from your
MyApp::Plugin::Blog plugin.  This can be done quite easily using the
Exporter module.  Here is a quick example of what you would put in
your plugin:

use strict;
use vars qw($VERSION @EXPORT @ISA);

require Exporter;

@ISA = qw(Exporter);
@EXPORT = qw(blog);

sub blog {
  blog blog blog
}

This all works through the 'import' method that is always called when
you 'use' a module.  For more details on exporting functions, see the
docs for Exporter, as well as perlfunc and perlmod.

Cheers,

Cees

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.