Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
@EXPORT_OK just tell what can be imported from this package. If you want to set some default things to be exported by the package you should set the array @EXPORT too.

Soo, @EXPORT_OK just tells what we can import explicity:

use nu qw( &some_funtion $var $array %etc ) ;
And @EXPORT set what the package export when you don't paste anything:
use nu ;
Take a look in the documentation of Export: http://www.perldoc.com/perl5.8.0/lib/Exporter.html

Other thing, try to build a pure Object-Oriented module, soo you will be able to use it in any type of application (console, GUI, CGI, mod_perl, etc...). One bad thing that you are doing is the action variablr, dependent of the arguments paste when the applications is executed by console.

Here's a simple example to start building an OO module:

package FOO ; use strict qw(vars); use vars qw($VERSION) ; $VERSION = '0.01' ; sub new { ## The class name: my $class = shift ; ## Arguments when creating the object: my ( $arg1 , $arg2 , @rest ) = @_ ; ## Define from what package this object will be: my $this = bless({} , $class) ; ## Define some internal value/attribute in the object: $this->{FOO} = $arg1 ; ## Return the created object: return $this ; } sub methodx { ## The object reference: my $this = shift ; ## Arguments of this method: my ( $arg1 , $arg2 , @rest ) = @_ ; ... } 1;
To use this module and create an object:
use FOO ; my $foo = new FOO("some args") ; my @returned = $foo->methodx("other args") ;

Graciliano M. P.
"Creativity is the expression of the liberty".


In reply to Re: Re: How to create a reusable routine ? by gmpassos
in thread How to create a reusable routine ? by bar10der

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2024-04-23 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found