I was hoping that someone can help me with this issue. I was able to create a use custom Perl modules from my previous employment, but am having an issue at this new job. Unlike the old job, I am not using the server version of perl, but instead, installed a local version to my home directory.

In this directory (/home/myhomedrive/script/prog1) I have this program called dupCheck.pl:

#!/home/myhomedrive/opt/perl/bin/perl #use strict; use warnings; use lib '/home/myhomedrive/scripts/lib'; use customPerlMod; my $string = " ll "; $string = trim ( $string );

As you can see from the code above, I have the custom module here: /home/myhomedrive/scripts/lib

Here is a snippet of my custom module (I have several different subroutines in it, but for the purposes of this question, I am showing only a few pieces of code):


#!/home/myhomedrive/opt/perl/bin/perl package customPerlMod; sub trim($) { my $string = shift; $string =~ s/^\s+//; $string =~ s/\s+$//; return $string; } # Left trim function to remove leading whitespace sub ltrim($) { my $string = shift; $string =~ s/^\s+//; return $string; } # Right trim function to remove trailing whitespace sub rtrim($) { my $string = shift; $string =~ s/\s+$//; return $string; } 1;

when I run the program, I get this at the command prompt:

./dupCheck.pl Undefined subroutine &main::trim called at ./dupCheck.pl line 20, <DAT +A> line 960.
any idea what I am doing wrong?


In reply to Trouble usig a subroutine from a custom module by fritz1968

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.