Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

script fails but succeeds in debugger

by codeacrobat (Chaplain)
on Dec 20, 2010 at 10:42 UTC ( #877977=perlquestion: print w/replies, xml ) Need Help??

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

Hello monks, I have experienced the phenomenon, that scripts with the latest Getopt::Long::Descriptive succeed in the debugger, but fail without. Can anyone explain why this happens or how to debug/fix these kind of issues?
> perl -v This is perl, v5.10.1 (*) built for i686-cygwin-thread-multi-64int (with 13 registered patches, see perl -V for more detail) # try the Getopt::Long::Descriptive Synopsis > perl synopsis.pl --help Reference found where even-sized list expected at /usr/lib/perl5/site_ +perl/5.10/Getopt/Long/Descriptive.pm line 442. Use of uninitialized value $arg{"name"} in hash element at /usr/lib/pe +rl5/site_perl/5.10/Getopt/Long/Descriptive.pm line 477. Use of uninitialized value in anonymous hash ({}) at /usr/lib/perl5/si +te_perl/5.10/Getopt/Long/Descriptive.pm line 486. Use of uninitialized value $arg{"name"} in hash element at /usr/lib/pe +rl5/site_perl/5.10/Getopt/Long/Descriptive.pm line 503. Reference found where even-sized list expected at /usr/lib/perl5/site_ +perl/5.10/ # works > env PERLDB_OPTS="NonStop=1" perl -d synopsis.pl --help my-program [-psv] [long options...] <some-arg> -s --server the server to connect to -p --port the port to connect to -v --verbose print extra stuff --help print usage message and exit
SOLVED A fresh reinstall of Params::Validate solved the issue.

print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});

Replies are listed 'Best First'.
Re: script fails but succeeds in debugger
by Anonyrnous Monk (Hermit) on Dec 20, 2010 at 11:21 UTC

    Can't reproduce the issue, i.e. it works fine for me without the debugger:

    #!/usr/bin/perl -w use strict; use Getopt::Long::Descriptive; my ($opt, $usage) = describe_options( 'my-program %o <some-arg>', [ 'server|s=s', "the server to connect to" ], [ 'port|p=i', "the port to connect to", { default => 79 } ], [], [ 'verbose|v', "print extra stuff" ], [ 'help', "print usage message and exit" ], ); print($usage->text), exit if $opt->help;
    $ ./877972.pl --help my-program [-psv] [long options...] <some-arg> -s --server the server to connect to -p --port the port to connect to -v --verbose print extra stuff --help print usage message and exit

    (tested with v5.10.1 (*) built for x86_64-linux-thread-multi)

    Update: as the first problem happens here:

    sub _validate_with { my (%arg) = validate(@_, { # <-- line 442 name => 1, params => 1, spec => 1, opts => 1, usage => 1, });

    and validate() is from Params::Validate, maybe there's some problem with this module? Which version are you using? (0.95 here)

      Ok it was Params::Validate. A fresh reinstall fixed the issue.

      I still would like to know how to better debug this issue.


      print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});
      Hi. I have the latest version.
      > perl -MParams::Validate -e 'print Params::Validate->VERSION' 0.95

      print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});
Re: script fails but succeeds in debugger
by mr_mischief (Monsignor) on Dec 20, 2010 at 12:05 UTC

    Like Anonyrnous Monk (clever name, by the way), I cannot duplicate the problem. I tried with 5.10.1, 5.12.2, and 5.13.4 on Linux. Perhaps it's a problem with the Cygwin Perl? I suppose I could hook up a Windows box to see, but I'm sure none of my Cygwin installations are current. Do you have Strawberry Perl or ActiveState Perl installed with which to test?

    This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi (with 1 registered patch, see perl -V for more detail)
    This is perl 5, version 12, subversion 2 (v5.12.2) built for x86_64-li +nux-ld
    This is perl 5, version 13, subversion 4 (v5.13.4) built for x86_64-li +nux-ld

Re: script fails but succeeds in debugger
by Anonymous Monk on Dec 20, 2010 at 11:10 UTC
    Could you show us the your code?
Re: script fails but succeeds in debugger
by codeacrobat (Chaplain) on Dec 20, 2010 at 11:39 UTC
    use Getopt::Long::Descriptive; my ($opt, $usage) = describe_options( 'my-program %o <some-arg>', [ 'server|s=s', "the server to connect to" ], [ 'port|p=i', "the port to connect to", { default => 79 } ], [], [ 'verbose|v', "print extra stuff" ], [ 'help', "print usage message and exit" ], ); print($usage->text), exit if $opt->help;

    print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});
      It works here:
      [~] perl -v | grep built This is perl, v5.10.1 (*) built for i686-cygwin-thread-multi-64int [~] perl -MGetopt::Long::Descriptive -E'say$Getopt::Long::Descriptive: +:VERSION' 0.087 [~] perl -MParams::Validate -E'say$Params::Validate::VERSION' 0.95 [~] perl -c 877988.pl 877988.pl syntax OK [~] perl 877988.pl [~] perl 877988.pl --help my-program [-psv] [long options...] <some-arg> -s --server the server to connect to -p --port the port to connect to -v --verbose print extra stuff --help print usage message and exit [~]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://877977]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2021-09-17 08:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?