hi,

i'm having some trouble with writing a module. i'm working under win32 and i would like to create a module. actually, just pass some subroutines into a module for organizing purposes. example:

"Test.pl" #use lib "./Nzd/"; ->not sure if this should be here #push @INC, "./Nzd/"; ->not sure if this should be here use strict; use warnings; use Nzd::NZD; #Nzd is a directory containing NZD.pm my ($x,$y)= (8,36); my $t=NZD($x,$y); my $c=$x/$t; my $g=$y/$t; print "\nc= $c, g= $g"; ------------------------------------ "NZD.pm" package Nzd::NZD; use strict; sub NZD { my ($x, $b) = @_; if ($x > $b){ ($x,$b) = ($b,$x); } while ($x) { ($x, $b) = ($b % $x, $x); } return $b; } 1;
as i tried to show i have 2 scripts *.pl and *.pm and from Test.pl i would like to call a sub NZD which is situated in NZD.pm, that is in a ./Nzd directory. and obviously i don't know how to do it. message i'm getting is that i didn't define the NZD sub

"Undefined subroutine &main::NZD called at Test.pl line 10."

where is the problem ?

i'm doing wrong...

thanks for all your help


In reply to how to write a module by baxy77bax

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.