in reply to Re^4: Trouble skipping lines using Perl
in thread Trouble skipping lines using Perl
So presumably next if ($_ = /^chrM/); would also be correct?
No! The $_ = /^chrM/ expression matches the regex against $_ (update: by default, since the // match is not explicitly bound to any other scalar by a =~ binding operator) and then assigns the result of the comparison | match to $_ (which at least gives $_ some defined value, so I guess it's not all bad :) Matching against $_ (or any other scalar variable) is only semantically correct if that variable has first been given some meaningful value as in a while (<FILE>) { ... } loop. Stick to
next if ($line =~ /^chrM/);
Give a man a fish: <%-{-{-{-<
|
|---|