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.
In reply to Trouble usig a subroutine from a custom module by fritz1968
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |