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

Charles,

Thanks for the tip on using join. Tad McClellan on comp.lang.perl.misc suggested the same thing.

Regarding the issue with if ($s->{terms}), I'm not getting any errors. my $terms is declared outside of the if statement block so I think that is keeping strict happy.

Thank you for taking the time to look at my code.

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

Replies are listed 'Best First'.
Re: Code Review Needed!
by CharlesClarkson (Curate) on Jul 02, 2001 at 22:20 UTC

    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.
      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