in reply to Re^2: Trouble skipping lines using Perl
in thread Trouble skipping lines using Perl
It didn't give you any warnings because the expression $chromosome = /^chrM/ is perfectly fine. It just doesn't do what you want it to. Instead of checking whether $chromosome starts with "chrM", it instead checks whether $_ starts with "chrM", and then sets $chromosome to a true value if it does, and a false value otherwise. Since you're not using $_ while parsing your lines, it never starts with "chrM" and always returns a false value.
It's a common enough mistake that I could see a case being made for "if ($var = /rex/)" generating a warning, as I expect that "if ($var = ($_ =~ /rex/))" is pretty uncommon (at least, when looking at my code).
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Trouble skipping lines using Perl
by LeBran (Initiate) on Nov 21, 2017 at 17:03 UTC | |
by AnomalousMonk (Archbishop) on Nov 21, 2017 at 17:23 UTC |