bill5262 has asked for the wisdom of the Perl Monks concerning the following question:

I have a module imported in my main perl file as the following:

use rns_fsq_jw;

The above contains a bunch of sub functions, and it seems to be working well except for one sub fuction:

ConnectFSQ()

This what I have under the rns_fsq_jw library:

sub ConnectFSQ #ipaddress { (do something blah blah blah) }

However, when I call the ConnectFSQ() function from my main script, I get the error saying "Undefined subroutine &main::ConnectFSQ called at ..."

my $IP_FSQ = "xxx.xxx.xxx.xxx"; # ip address ... (blah blah blah) ConnectFSQ($IP_FSQ);

Am I doing something wrong?

Replies are listed 'Best First'.
Re: Error saying “Undefined subroutine xxx called at…”
by VinsWorldcom (Prior) on Jul 26, 2016 at 02:21 UTC

    Without the code of the module, I'm going to guess that the module is not exporting the ConnectFSQ() sub. When you call it from your script, the error is saying that ConnectFSQ() is not found in your script's namespace.

    Try:

    my $IP_FSQ = "xxx.xxx.xxx.xxx"; # ip address ... (blah blah blah) rns_fsq_jw::ConnectFSQ($IP_FSQ);
Re: Error saying “Undefined subroutine xxx called at…”
by Anonymous Monk on Jul 26, 2016 at 02:19 UTC

    Am I doing something wrong?

    You're giving a description of your code, instead of giving actual code that shows the error

    The error you get is simple/easy to understand, but a description of code isn't going to demonstrate the error

    For example

    $ perl -e" Demo(); " Undefined subroutine &main::Demo called at -e line 1. $ perl -e" sub demo {warn 666} Demo(); " Undefined subroutine &main::Demo called at -e line 1. $ perl -e" package Demo;sub Demo {warn 666}; package main; Demo(); " Undefined subroutine &main::Demo called at -e line 1.

    The problem is obvious, first there is no Demo, then there is no Demo ("demo" is not "Demo"), then there is no Demo again