Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: A better way to make the script run faster?

by tobyink (Abbot)
on Jul 31, 2013 at 13:22 UTC ( #1047265=note: print w/replies, xml ) Need Help??

in reply to A better way to make the script run faster?

Use a frickin hash!

use strict; use warnings; my @gl = qw( CD9 TBN NANOG KITL FUT4 SALL4 MYC STAT3 ESRRB AKP2 SOX2 POU5F1 KLF4 ); my @hfr_genes = qw( LYPLA1 LYPLA1 LYPLA1 LYPLA1 STAT3 LYPLA1 LYPLA1 STAT3 LYPLA1 LYPLA1 LYPLA1 LYPLA1 SOX2 ); # First thing: convert @hfr_genes into a hash!!! # Looking up a hash key is much faster than grepping an array. my %hfr_genes; $hfr_genes{$_}++ for @hfr_genes; # Now loop through the first list for (@gl) { my $count = $hfr_genes{$_}; print "Value $_ is present $count times\n" if $count; }
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1047265]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2018-04-26 18:07 GMT
Find Nodes?
    Voting Booth?