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

I see some use of "::die_bug" in Perl code found on the internet. I can't find any documentation for it. Using it under "This is perl 5, version 26, subversion 2 (v5.26.2) built for MSWin32-x64-multi-thread" gives the error: Undefined subroutine &main::die_bug called at ./check_shell.pl line 662.

It works in "This is perl 5, version 18, subversion 4 (v5.18.4) built for x86_64-linux"

Replies are listed 'Best First'.
Re: Documentation for die_bug
by haukex (Archbishop) on Jan 18, 2019 at 19:51 UTC

    There is no mention of a die_bug in the Perl core either in version v5.18.4 or v5.26.2, nor anywhere on PerlMonks. The most common mention I can find on the net, and the only mention on CPAN, is apparently in the source of GNU Parallel, where it is currently defined as follows:

    sub die_bug { my $bugid = shift; print STDERR ("$Global::progname: This should not happen. You have found a bug. +\n", "Please contact <parallel\@gnu.org> and follow\n", "https://www.gnu.org/software/parallel/man.html#REPORTING-BUGS\n" +, "\n", "Include this in the report:\n", "* The version number: $Global::version\n", "* The bugid: $bugid\n", "* The command line being run\n", "* The files being read (put the files on a webserver if they are + big)\n", "\n", "If you get the error on smaller/fewer files, please include thos +e instead.\n"); ::wait_and_exit(255); }

    I don't know why you'd see a difference between Perl versions (Update: ... except for the difference between Linux and Windows, as noted by bliako. The following advice still applies). Please show a Short, Self-Contained, Correct Example that reproduces the issue, i.e. a short piece of code that works on v5.18 and fails on v5.26.

Re: Documentation for die_bug
by bliako (Abbot) on Jan 18, 2019 at 20:51 UTC

    The name of the script is check_shell.pl and it fails on Windows but it works on Linux.

    Hmmm, my heuristics tell me that finding the missing body of die_bug() is the least of your problems ...

    bw, bliako

Re: Documentation for die_bug
by Anonymous Monk on Jan 18, 2019 at 17:53 UTC
    show the code
Re: Documentation for die_bug
by dhvsfan (Initiate) on Jan 21, 2019 at 16:30 UTC

    Guys, working on a small example for this question. The code I was using was taken from:

    https://stackoverflow.com/questions/23937389/determine-parent-shell-from-perl/25139489

    See the code just below the statement: The solution became this, which does not depend on a C-compiler.

      The code in that SO answer seems to simply be a subset of the source of GNU Parallel, which I linked to before. There are several definitions missing from that snippet: debug, die_bug, wait_and_exit, plus several global variables. I don't think it's meant to be used as a standalone snippet. However, because it seems like those functions are mostly helpers, you could simply remove the calls to ::debug() and replace ::die_bug with die, and then the code seems to work for me (aside from some warnings about undef, although it seems GNU Parallel doesn't use warnings...).

      Update: I've edited the StackOverflow answer to remove the dependencies on those two undefined functions, the code should now be standalone.