in reply to Re^3: Removing partially duplicated lines from a file
in thread Removing partially duplicated lines from a file
... that first check ... a better way to avoid that warning ... something like exists ...
defined is the way I would typically finesse this problem:
if (defined($columns[1]) && $columns[1] =~ /^HLA-A/) {
...
}
In the case of your posted code, the empty string and '0' will not, as you say, be tested against the regex, and in this particular case it will not matter because they cannot match anyway. In the general case, I think it's better to use defined because you can better avoid the "It'll never happen... Oh, it does happen..." situations that lead to those wonderful 3 AM debug sessions.
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Removing partially duplicated lines from a file
by perldigious (Priest) on Jul 27, 2016 at 13:03 UTC | |
by AnomalousMonk (Archbishop) on Jul 27, 2016 at 15:36 UTC | |
by perldigious (Priest) on Jul 27, 2016 at 15:50 UTC |