Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: starting perl module

by kennethk (Abbot)
on Jul 28, 2010 at 13:55 UTC ( #851718=note: print w/replies, xml ) Need Help??


in reply to starting perl module

First, I would like to second JavaFan's comments above.

A Perl module that is not designed to be invoked with objects can really be thought of more as a library. I actually use non-OO modules far more often, since my background is Procedural_programming. If you are interested in working with Perl in an object-oriented context, I would suggest reading perlboot and perltoot to understand the mechanics and probably use Moose or Mouse as the framework rather than rolling your own.

I will assume the tutorial you read was Simple Module Tutorial. With regard to non-OO approaches, I'd recommend reading perlmod. I'd also point out that the examples in Simple Module Tutorial include the pragma vars to declare the variables required by Exporter. As vars states,

NOTE: For variables in the current package, the functionality provided by this pragma has been superseded by our declarations, available in Perl v5.6.0 or later. See our.

This means the module at the top of that thread should likely read:

package MyModule; use strict; use Exporter; our $VERSION = 1.00; our @ISA = qw(Exporter); our @EXPORT = (); our @EXPORT_OK = qw(func1 func2); our %EXPORT_TAGS = ( DEFAULT => [qw(&func1)], Both => [qw(&func1 &func2)]); sub func1 { return reverse @_ } sub func2 { return map{ uc }@_ } 1;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://851718]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2022-10-02 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (11 votes). Check out past polls.

    Notices?