in reply to Re^2: Skript help needed - RegEx & Hashes
in thread Skript help needed - RegEx & Hashes

$h->{"5p-tR-halves"} += $line[ 1] / $reads * 1000000; $h->{"5p-tRFs"} += $line[ 3] / $reads * 1000000; $h->{"3p-tR-halves"} += $line[ 5] / $reads * 1000000; $h->{"3p-CCA-tRFs"} += $line[ 7] / $reads * 1000000; $h->{"3p-tRFs"} += $line[ 9] / $reads * 1000000; $h->{"tRF-1"} += $line[11] / $reads * 1000000; $h->{"tRNA-leader"} += $line[13] / $reads * 1000000; $h->{"misc-tRFs"} += $line[15] / $reads * 1000000;

Years ago that would not have bothered me but nowadays it makes me twitch. YMMV but for DRY:

my $i = 1; for (qw/5p-tR-halves 5p-tRFs 3p-tR-halves 3p-CCA-tRFs 3p-tRFs tRF-1 tR +NA-leader misc-tRFs/) { $->{$_} += $line[$i] / $reads * 1000000; $i += 2; # Odd entries only }

Replies are listed 'Best First'.
Re^4: Script help needed - RegEx & Hashes (DRY)
by haukex (Archbishop) on Oct 12, 2018 at 12:30 UTC

    I thought about doing something like that, but ended up leaving it out - I should've added it, since I agree with you!