gry wrote:
[[v5.8.8 built for x86_64-linux-thread-multi]
#!/usr/bin/perl -W
use Getopt::Long;
my $dml = 0;
my $iterations = 10;

my %options = ("dml!" =>  \$dml,
               "iterations=i" =>  \$iterations);
GetOptions(%options) || die "bad options";
printf "dml=$dml\n";

That should be either:

print "dml=$dml\n";

Or:

printf "dml=%s\n", $dml;


print %options;
foreach $key (sort keys %options) {
     printf "$key: $options{$key}\n";}

That should be either:

     print "$key: $options{$key}\n";}

Or:

     printf "%s: %s\n", $key, $options{$key};}

$options{$key} contains a reference to a scalar so you have to dereference it:

     print "$key: ${$options{$key}}\n";}

Or:

     printf "%s: %s\n", $key, ${$options{$key}};}


This script prints:
dml=0
dml!SCALAR(0xa461540)iterations=iSCALAR(0xa461560)dml!:
SCALAR(0xa461540)
iterations=i: SCALAR(0xa461560)

How can I get readable output of my getopt options without manually
enumerating them?



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to