On Feb 9, 8:13 pm, shawnhco...@gmail.com (Shawn H Corey) wrote: > On 11-02-09 04:52 PM, 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"; > > print %options; > > foreach $key (sort keys %options) { > > printf "$key: $options{$key}\n";} > > > 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? > > With Getopt::Long, the value of the options is in the variable: > > print "\$dml = $dml\n"; > print "\iterations = $iterations\n"; Thanks, Shawn. I understand that I can explicitly print each variable, as you show. But what I want to do is iterate through the hash, printing "name=value" for each option. Otherwise, when I add/delete/change options, I would have to reflect this in the printing statements. Is there some way to dereference these "SCALAR" things, or a better way to refer to the values from the hash? > > -- > Just my 0.00000002 million dollars worth, > Shawn
-- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/