Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implies condition sometimes results in uninitialized value, sometimes it just works #38

Open
gversluis opened this issue Sep 27, 2021 · 1 comment

Comments

@gversluis
Copy link

The output of the code below on Ubuntu 16.04 (everything from Ubuntu repo) gives:

:!./test.pl -t 127.0.0.1 --ip

ip: 1
Use of uninitialized value in print at ./test.pl line 18.
Status:

But about 50% of the times it gives the expected output:

:!./test.pl -t 127.0.0.1 --ip

ip: 1
Status: open

Code:

#!/usr/bin/perl -w -T

use strict;
use Getopt::Long::Descriptive;


my ($opt, $usage) = describe_options(
  '',
  [ 'ip',       "Get WAN IP address" ],
  [ 'status=s',   "Change service status", { callbacks => {
    'Accepted status values are: OPEN, CLOSE' => sub { $_[0] =~ /^(open|close)$/  }
  } } ],
  [ 'target|t=s',   "Target IPv4 when a port is opened", { implies => { status => 'open' }, callbacks => {
    'Valid ipv4' => sub { $_[0] =~ /^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$/ }
  } } ],
);

print "\nip: ", $opt->ip(), "\nStatus: ", $opt->status(), "\n";

exit;
@gversluis
Copy link
Author

Issue is still there in v0.109 (current trunk)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant