On Dec 12, 9:45 pm, [EMAIL PROTECTED] (Dr.Ruud) wrote:
> protoplasm schreef:
>
> > foreach (keys %opts_hash)
> > {
> > if ( !defined $opts_hash{$_} )
> > {
> > next;
> > }
> > elsif ( $opts_hash{$_} == 1 )
> > {
> > print "$_ = $opts_hash{$_}\n";
> > }
> > }
>
> An alternative w
protoplasm schreef:
> foreach (keys %opts_hash)
> {
> if ( !defined $opts_hash{$_} )
> {
> next;
> }
> elsif ( $opts_hash{$_} == 1 )
> {
> print "$_ = $opts_hash{$_}\n";
> }
> }
An alternative way to write that:
for (sort keys %opts_hash) {
next unless defined $opts_hash
Thanks for the advice. After I posted I tried this and it worked too:
foreach (keys %opts_hash)
{
# This next line of code eliminates the "Use of uninitialized value
in
# numeric eq (==)" error when 'use warnings;' is enabled.
if (
way that will not
autovivify all the keys is:
GetOptions( \my %opts_hash,
'allTests', 'CbcDec', 'CbcEnc', 'CfbDec', 'CfbEnc', 'CtrDec',
'CtrEnc', 'EcbDec', 'EcbEnc', 'OfbDec', 'OfbEnc',
On Dec 11, 2007 7:53 PM, protoplasm <[EMAIL PROTECTED]> wrote:
snip
> my $opts_hash;
> my %opts_hash = ();
snip
You don't need $opts_hash (you aren't using it). You can get rid of
the undef warnings by making sure that the keys in %opts_hash are used
like this:
#default values for the options
my
each (keys %opts_hash)
{
if ( $opts_hash{$_} == 0 )
{
next;
}
elsif ( $opts_hash{$_} == 1 )
{
print "$_ = $opts_hash{$_}\n";
}
}
==========
naiad:~/workspace $ ./debug2.pl --CbcDec
Use of unini