subroutines and modules

DBSMITH_at_OhioHealth.com
Date: 09/29/04


To: beginners@perl.org
Date: Wed, 29 Sep 2004 14:54:32 -0400

Perl'ers

I am reading Object Oriented Perl pages 52 and 53 for setting up a module.
 It is telling me in order to use a routine from a different file you have
to

1) choose a lib directory
2) export PERL5LIB=.../.../.../
    use lib /usr/local/perl/my.pl
3) created nested subdirs for each component of the module name
4) create a text file in the last directory
5) Insert you code.
6) add 1; at then end of the perl program file.

NOTE: is says in the footer that I can use h2xs to combine steps 3 and 4.
 

My quesiton is can't I just use step 2 and then in my program where I want
to use this code, make a routine call?
My goal is to set up a module for a routine that I can pass a data file
to, from a different file so it can read this file in then execute.
an example would be : &routine(datafile);

I then looked into Perl Cookbook ch 12_02 and it discussed :

In module file YourModule.pm, place the following code. Fill in the ellipses as explained in the
Discussion section.
package YourModule;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);

use Exporter;
$VERSION = 1.00; # Or higher
@ISA = qw(Exporter);

@EXPORT = qw(...); # Symbols to autoexport (:DEFAULT tag)
@EXPORT_OK = qw(...); # Symbols to export on request
%EXPORT_TAGS = ( # Define names for sets of symbols
    TAG1 => [...],
    TAG2 => [...],
    ...
);

########################
# your code goes here
########################

1; # this should be your last line

Is one autoloader and self loader? It seems to me I am getting
conflicting info of just that I am not understanding?

thanks, derek



Relevant Pages

  • Re: Passing an array to a sub routine
    ... but later you're using a hash. ... In Perl, these are very ... The LoadDataFile routine works correctly, ...
    (comp.lang.perl.misc)
  • Re: modules
    ... It is telling me in order to use a routine from a different ... > 1) choose a lib directory ... _Perl Cookbook_ is giving you the cookbook answer, suitable for cutting, ... _Object Oriented Perl_ is trying to teach you to ...
    (perl.beginners)
  • Re: Is Perl *that* good? (was: Hows ruby compare to it older brother python)
    ... >The routine is for a phonetic search in Norwegian 18th century names, ... >that the Soundex algorithm was useless for Norwegian spellings, ... >I use a Perl script to transform my genealogy data from a FoxPro ... >maintain both a PHP and a Perl version of the same routine. ...
    (comp.lang.python)
  • Re: modules
    ... Please respond to Perl Beginners List ... It is telling me in order to use a routine from a different ... > 1) choose a lib directory ... _Perl Cookbook_ is giving you the cookbook answer, suitable for cutting, ...
    (perl.beginners)
  • Re: Is Perl *that* good?
    ... the web routine for phonetic searches might have been ... >> maintain both a PHP and a Perl version of the same routine. ...
    (comp.lang.python)