in reply to Trouble skipping lines using Perl
So the code could be made significantly shorter (and probably slightly faster) as follows, without losing any clarity:
I'm not saying that your code was bad, it wasn't, but I'm just trying to show some opportunities for improvement.while (my $line = <FILE>) { next if $. == 1; next if $line =~ /^\s*chrM/; my ($chromosome, $nmreads, $mutants) = (split "\t", $line)[0, 8, 9 +]; # note: $chromosome is not used, this could be simplified further my $totalreads = $nmreads + $mutants; print ("$nmreads $mutants $totalreads\n"); }
Update: Fixed a typo (s/loosing/losing/), thanks to 1nickt for letting me know.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trouble skipping lines using Perl
by LeBran (Initiate) on Nov 22, 2017 at 11:06 UTC |