Apache-Perl: mod_perl error

Ryan Nielsen ffl at asphaltzipper.com
Fri Feb 4 16:05:57 MST 2005


Tyler Bird wrote the following on 2/4/2005 3:07 PM :

>Are you using Apache::Registry or another handler?  
>Perl scripts should run without any modifications with under
>mod_perl/Apache::Registry
>if it's setup right.  What are you trying to do? 
>
>Try using perl directly.
>
>I personally only have modules and use "use" instead of require.
>I then export symbols into the calling packages namespace using
>exporter.
>You can make your module like this
>
>-- start file ---
># Package Declaration
>package yourPackageOrLibraryName;
>
># Exporter Module used to export names from this module
>use Exporter;
>
>#--------------------------------------------------------------------
># Inherit from Exporter module
># to put symbols in calling packages
># namespace, put symbols ( names of functions ) in @EXPORT array
># you can put functions in the @EXPORT_OK array but you have
># to specify explicitly those routines with the use statment in the
># calling package
>#--------------------------------------------------------------------
>
># Here you put your inherted modules in the @ISA array
># We need to Inherted from Exporter to easily export symbols 
>@ISA=('Exporter');
>
># @EXPORT_OK array allows us to selectively specify in the use 
># which symbols to import
># for example in the ::main package
># use yourPackageOrLibraryName('func1', 'func2');
># @EXPORT will export all symbols when you in the using module 
># do not include any symbols for example
># use yourPackageOrLibraryName; 
>
>@EXPORT = ('parse', 'header', 'end_html', 'html_head', 'side_bar');
>
># put subroutines & other symbols below
>
>-- end file --
>
>Or do OO library
>
>#--------------------------------------------------------------------------------------------------------------
>package myPackage;
>#--------------------------------------------------------------------------------------------------------------
>use DBI;
>use cgiutils;
>
>#--------------------------------------------------------------------------------------------------------------
># Constructor
>#--------------------------------------------------------------------------------------------------------------
>sub new
>{
>my($pkg, $name, $age) = @_;
>
># must return blessed refrence
>return  bless(  { "field1" => "value" }, $pkg );
>
>}
>
>#--------------------------------------------------------------------------------------------------------------
># Destructor
>#--------------------------------------------------------------------------------------------------------------
>sub DESTROY
>{
>my $obj = shift;
>$obj->{"dbh"}->dissconnect();	
>}
>
>#--------------------------------------------------------------------------------------------------------------
>sub foo
>{	
>}
>
>--- snip ---
>
>then use it in another module like the main module like so
>
>use MyPackage;
>
>$obj = new MyPackage();
>  
>
Thanks for the example Tyler.  I will try this!



More information about the PLUG mailing list