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

oh oh! Try this #146

Closed
p5pRT opened this issue Jul 2, 1999 · 1 comment
Closed

oh oh! Try this #146

p5pRT opened this issue Jul 2, 1999 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Jul 2, 1999

Migrated from rt.perl.org#951 (status was 'resolved')

Searchable as RT951$

@p5pRT
Copy link
Author

p5pRT commented Jul 2, 1999

From cabney@cyberpass.net

Try invoking this with and without the -D flag and note the behavior of
$DEBUG​:
====================<test1.pl>====================
#!/usr/bin/perl -w
use Getopt​::Std;

getopts('pDd​:f​:');
print "opt-D is​: $opt_D\n";

# if it's on the command line w/no arg it gets a 1
$opt_D ? $DEBUG = 1 : $DEBUG = 0;

print "opt-D is​: $opt_D\n";
print "DEBUG is​: $DEBUG\n";
====================<test1.pl>====================

Ok, this is how it /should/ behave​:
====================<test2.pl>====================
#!/usr/bin/perl -w
use Getopt​::Std;

getopts('pDd​:f​:');
print "opt-D is​: $opt_D\n";

# if it's on the command line w/no arg it gets a 1
$opt_D ? foo(1) : foo(0);

print "opt-D is​: $opt_D\n";
print "DEBUG is​: $DEBUG\n";

sub foo {
  $DEBUG = shift;
}
====================<test2.pl>====================

Forgive me if this is a FAQ, or a 'feature', but it looks like
assignments aren't being carried out inside the 'x ? y : z'
thinger. Is this a bug?

-C
--
Einstein himself said that God doesn't roll dice. But he was wrong. And
in fact, anyone who has played role-playing games knows that God
probably had to roll quite a few dice to come up with a character like
Einstein. -- Larry Wall C. Abney

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

No branches or pull requests

1 participant