On Thu, 7 Jun 2001, Peter Cline wrote:
> Thank you!  You hit the nail on the head.  Changing the offending line so
> that it is wrapped as such:
>
>   if ($input =~ /$$varValueSep/) {
>           ($var, $value) = split(/$$varValueSep/, $input);
>        }
>
> eliminates the warnings.

You also have the code...

($var, $value) = split(/$$varValueSep/, $input);
if (($var ne "") && ($value ne "")) {

...which will generate warnings if there are not two values in $input
to be split.

You can fix that in three ways I can think of off the top of my head..
others could probably come up with thirty more.  The first is to make sure
the values have been defined with the 'defined' keyword.

($var, $value) = split(/$$varValueSep/, $input);
if (defined $var and $var ne "" and
    defined $value and $value ne "")

The second is to check the number of values split returns.

if ( (scalar(($var, $value) = split(/$$varValueSep/, $input)) ) == 2
    and $var ne "" and $value ne "") {

The third, and my favorite is to use a regex.

if ($input =~ /(.+)$$varValueSep(.+)/) {
  ($var, $value) = ($1, $2);

This assumes that the seperator only appears once.  The match will
fail if it does not find something on both sides of teh seperator.

--
Ian

Reply via email to