in reply to Re: Re: Code Review Needed!
in thread Code Review Needed!

Your not getting any errors because $s->{terms} always tests true. What if one day it tests false? That is why your testing it.

If it does test false one day, $terms will be undef and strict will throw an 'unitialized' error here:

# Assign the inserted values $s->{insert} = { all => [ "%All%", $all ], any => [ "%Any%", $any ], terms => [ "%Terms%", $terms ], . . .

HTH,
Charles K. Clarkson

Biologists have a word for something that doesn’t change: dead.

Replies are listed 'Best First'.
Re: Re: Code Review Needed!
by redsquirrel (Hermit) on Jul 02, 2001 at 22:58 UTC
    What is the best way to keep these 'uninitialized' errors from appearing? When I declare my $terms, should I set it to empty quotes or is there a better way?

    Thanks for the help,

    Dave Hoover
    "Twice blessed is help unlooked for." --Tolkien
    http://www.redsquirreldesign.com/dave

      Either that or use a default value

      # Load the keywords used my $terms = ''; if ($s->{terms}) { $terms = join ' ', @{$s->{terms}}; }
      or:
      # Load the keywords used my $terms = 'some default value'; if ($s->{terms}) { $terms = join ' ', @{$s->{terms}}; }

      Or, even better might be to allow Soapbox.pm to handle undef values


      HTH,
      Charles K. Clarkson