fritz1968 has asked for the wisdom of the Perl Monks concerning the following question:
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:
any idea what I am doing wrong?./dupCheck.pl Undefined subroutine &main::trim called at ./dupCheck.pl line 20, <DAT +A> line 960.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Trouble usig a subroutine from a custom module
by choroba (Cardinal) on Nov 08, 2024 at 18:40 UTC | |
by stevieb (Canon) on Nov 09, 2024 at 08:48 UTC | |
by fritz1968 (Sexton) on Nov 11, 2024 at 16:01 UTC | |
by choroba (Cardinal) on Nov 11, 2024 at 16:23 UTC | |
by fritz1968 (Sexton) on Nov 11, 2024 at 21:34 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |