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?


In reply to How can I debug a weird "Undefined subroutine..." error that should be defined. by dly

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.