in reply to Re^2: Is this logic correct? Maybe can be rewritten better?
in thread Is this logic correct? Maybe can be rewritten better?
When you use my $hostmatch inside the if, you're creating a variable that only exists within the if. Any value you assign to it will disappear along with the variable once outside the if. That means elsif( $hostmatch == 1 ) is using a variable that no longer exists. The solution is:
my $hostmatch; while( $row = $sth->fetchrow_hashref ) { if( $host eq $row->{host} ) { $hostmatch = 1; } }
Same goes for $data. Change
if( param('select') and param('select') !~ /\.\./ ) { my $data = ... ... }
to
my $data; if( param('select') and param('select') !~ /\.\./ ) { $data = ... ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |