dly has asked for the wisdom of the Perl Monks concerning the following question:
Apologies for no real code, but the simple case does not exhibit my problem, only my real world case needing an FTP server set up exhibits the problem.
The Simple code:
# OVERRIDE_BUILD imports run_star_commands(). use App::Fetchware qw(:OVERRIDE_BUILD); run_star_commands();
seems to work just fine :(
But my complicated test environment involving a test FTP server exhibits this problem (Partial code listing):
... use Sub::Mage 'sublist'; diag("WEBAPPSLOADED!!!!!!!!!!!["); print "$_\n" for sublist(); diag("]"); use B::Deparse; my $deparse = B::Deparse->new("-p", "-sC"); my $body = $deparse->coderef2text(\&run_star_commands); diag("RUNSTARCOMMANDS["); diag("$body"); diag("]"); # Use run_start_commands from :OVERRIDE_BUILD to support uploa +d_commands # being a true ONEARRREF and having multiple commands to call. run_star_commmands(@upload_commands); } else { ...
That has the following output:
# WEBAPPSLOADED!!!!!!!!!!![ have after DATA_PROT_CONFIDENTIAL ... run_star_commands ... constructor filter splitpath CMD_OK download_dirlist # ] # RUNSTARCOMMANDS[ # { # package App::Fetchware; # use warnings; # use strict; # no feature; # use feature ':5.10'; # (my(@star_commands) = @_); # foreach my $star_command (@star_commands) { # if (($star_command =~ /,\s*/)) { # (my(@star_commands) = split(/,\s*/, $star_command, 0)); # foreach my $split_star_command (@star_commands) { # run_prog($split_star_command); # } # } else { # run_prog($star_command); # } # } # } # ] Undefined subroutine &App::FetchwareX::WebApp::run_star_commmands call +ed at /home/dly/Desktop/Code/App-Fetchware/lib/App/FetchwareX/WebApp +.pm line 768 (#2) (F) The subroutine indicated hasn't been defined, or if it was, it + has since been undefined. Uncaught exception from user code: Undefined subroutine &App::FetchwareX::WebApp::run_star_commma +nds called at /home/dly/Desktop/Code/App-Fetchware/lib/App/FetchwareX +/WebApp.pm line 768. at /home/dly/Desktop/Code/App-Fetchware/lib/App/FetchwareX/WebApp.pm +line 768. App::FetchwareX::WebApp::build('a') called at t/App-FetchwareX +-WebApp.t line 733 # Tests were run but no plan was declared and done_testing() was not s +een. # Looks like your test exited with 25 just after 5. Dubious, test returned 25 (wstat 6400, 0x1900) Failed 1/6 subtests Test Summary Report ------------------- t/App-FetchwareX-WebApp.t (Wstat: 6400 Tests: 6 Failed: 1) Failed test: 5 Non-zero exit status: 25 Parse errors: No plan found in TAP output Files=1, Tests=6, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.36 cusr + 0.12 csys = 0.52 CPU) Result: FAIL
As you can see from the output right before I call run_star_commands() I call Sub::Mage's sublist() subroutine that returns all subroutines defined in the current package. I snipped the output, but the important part is that run_star_commands() is listed.
I also use B::Deparse to deparse run_star_commands() to see if run_star_commands() can be deparsed, and it deparses it just fine.
Then the very next thing I do is call run_star_commands(), but it fails with an "Undefined subroutine" error message.
My test setup is a real disaster, so testing my code would require installing a bunch of modules, setting some crazy environment variables, and access to a FTP server. So, instead of asking you guys to git clone my repo, set insane environment variables, and setup an FTP server, what I'm looking for is a way to debug this problem myself.
Could setting a watchpoint in the debugger for run_star_commands() reveal what's making it vanish without a trace right before perl calls it? Watchpoints only seem to work for regular variables as using something like:
w $App::FetchwareX::WebApp{run_star_commands}{CODE}
causes the debugger to freak out. Is their some sort of way of accessing a subroutine "as a variable", so that I can set a watch expression on it to see where it changes?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I debug a weird "Undefined subroutine..." error that should be defined.
by Corion (Patriarch) on Mar 01, 2015 at 09:01 UTC | |
by dly (Beadle) on Mar 01, 2015 at 09:56 UTC | |
|
Re: How can I debug a weird "Undefined subroutine..." error that should be defined.
by Mr. Muskrat (Canon) on Mar 03, 2015 at 18:02 UTC | |
by Mr. Muskrat (Canon) on Mar 03, 2015 at 20:36 UTC |