blackjudas has asked for the wisdom of the Perl Monks concerning the following question:
At some point the vars $row->[0] and $row->[1] were empty, this eventually broke a few other parts of the code which depended on this information. What I was wanting to do is act on the variables if the $row vars were empty, rather than checking for a value I assumed I could act if $! had a value.for my $row (@{$dates}) { $seasons{'low'} = $row->[0] if ($row->[0] < $seasons{'low'}); $seasons{'high'} = $row->[1] if ($row->[1] > $seasons{'high'}); }
The theory behind it was that if an uninitialized var was being used a warning would pop up and I would print the corresponding id to let me know if it was empty.for my $row (@{$dates}) { $seasons{'low'} = $row->[0] if ($row->[0] < $seasons{'low'}); print "$row->[2]\n" if $!; $seasons{'high'} = $row->[1] if ($row->[1] > $seasons{'high'}); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trapping a warning
by chromatic (Archbishop) on Jul 03, 2002 at 22:04 UTC | |
|
Re: Trapping a warning
by zaimoni (Beadle) on Jul 03, 2002 at 22:40 UTC | |
by Abigail-II (Bishop) on Jul 04, 2002 at 11:15 UTC | |
|
Re: Trapping a warning
by Jim Morrison (Novice) on Jul 03, 2002 at 21:55 UTC | |
|
Re: Trapping a warning
by blackjudas (Pilgrim) on Jul 04, 2002 at 17:49 UTC |