in reply to Undefined subroutine &main::func1 [SOLVED]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Undefined subroutine &main::func1
by afoken (Chancellor) on Jun 28, 2015 at 14:29 UTC | |
What looks most suspicious to me (and perhaps to kcott), are the '&' sigils in your use and %EXPORT_TAGS. The ampersand is optional, but legal in the exporter variables (@EXPORT and @EXPORT_OK). Quoting Exporter:
From that, I conclude that the ampersand is optional, but not recommended also in %EXPORT_TAGS and in parameters for import() (i.e. after use and require). The source code of Exporter actively removes leading ampersands in sub import:
The same logic also exists in Exporter::Heavy:
Exporter::Heavy even adds ampersand prefixes sometimes:
Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-) | [reply] [d/l] [select] |
by soonix (Chancellor) on Jun 28, 2015 at 15:25 UTC | |
Ah. I think I mixed that up with the inadvertently-prototype-creating use of '()'. Thank you for the elaborated enlightenment. I must admit that I hadn't run the "problematic" code. I just did, and made the following observations. | [reply] [d/l] [select] |
by thanos1983 (Parson) on Jun 28, 2015 at 15:35 UTC | |
Hello afoken, Thank you for your time and effort reading and replying to my query. Well after a lot of experimentation I have concluded that the problem lies with the directories. I am using Net::SNTP::Client.pm which I have install it locally. I assume since the moment that I install it locally since then any modification I am applying on the module is ignored because I can see the installed directory Net-SNTP-Client. So I assume that I first need to uninstall the module and then find a way to experiment with the module before installing it. I have tried almost 100 different combinations with the use lib '/home/username/ModuleFolder/'; but I keep getting the same error:
I have unistalled my module since I think this is the root of all problems before I move to the next step I need to find a way to make it work. Sample of Module Net::SNTP::Client.pm:
Sample of code for script client.pl:
Seeking for Perl wisdom...on the process of learning...not there...yet!
| [reply] [d/l] [select] |
by soonix (Chancellor) on Jun 28, 2015 at 16:37 UTC | |
| [reply] [d/l] [select] |
|
Re^2: Undefined subroutine &main::func1
by thanos1983 (Parson) on Jun 28, 2015 at 14:28 UTC | |
Hello soonix, Thank you for your time and effort reading and reviewing my code. Well if I am not mistaken (I am not really sure since I have no experience with reusable modules) that the '&' is not affecting the code on %EXPORT_TAGS because I am not using them, not yet at least. Based on the example Simple Module Tutorial the author is using these sigils and they work fine, I just tested it. I assume the error comes from the Directories that I using Net::SNTP:Client.pm can not be used without been installed. Or maybe I am doing many wrong assumptions. Any way I am still working on it to learn more about it, thank you for your time and effort again.
Seeking for Perl wisdom...on the process of learning...not there...yet!
| [reply] [d/l] [select] |
by soonix (Chancellor) on Jun 28, 2015 at 15:26 UTC | |
| [reply] | |
by thanos1983 (Parson) on Jun 28, 2015 at 15:58 UTC | |
Hello soonix, OMG I just figure it out. Not knowing something can lead to so many mistakes and disappointment! You are absolutely right, The way that I define my folders on my module was completely wrong! I had named a module literally Net::SNTP::Client.pm although that I read that when the module will be installed this will mean that will be in the directory Net/SNTP/Client I completely forgot about it and proceed with naming the module like this. Of course when loading the module it was not able to see the directory since they do not match. So I simply used the use lib '/home/username/Desktop/Test/'; before loading my module and modified also the directories accordingly. I had to rename my module to Client.pm instead of Net::SNTP::Client.pm and voilą! Sample of modified code for simplicity:
Expected output:
Apologies for not able to understand and explain my problem properly. I have confused too many people that tried to help me.
Seeking for Perl wisdom...on the process of learning...not there...yet!
| [reply] [d/l] [select] |