open IN, '<', $ARGV[0]; my %hash1; while () { next unless ( $_ =~ m/^\@HWI/ ); my ($header) = split(/ /, $_); $hash1{$header} = 1; } close IN; open IN2, '<', $ARGV[1]; my %hash2; while () { next unless ( $_ =~ m/^\@HWI/ ); my ($header) = split(/ /, $_); $hash2{$header} = 1; } close IN; #### my @threads = ("1","2"); # Loop through the array: foreach(@threads){ # Tell each thread to perform our 'parseLines()' subroutine. $_ = threads->create(\&parseLines, shift(@ARGV)); } #Tries to join the running threads #Some check implemented to avoid quitting the loop, before everything is joined my @running = threads->list(threads::running); #Array of running threads my @joinable = threads->list(threads::joinable); #Array of joinable threads my @catcher; while (scalar(@running) != 0 || scalar(@joinable) > 0) { #While as long as there are running or joinable threads @running = threads->list(threads::running); #Repopulate running, not sure if needed. foreach(@threads){ if ($_->is_joinable()) { push(@catcher, $_->join()); #Put's parsed file as hash-ref into array } } @joinable = threads->list(threads::joinable); @running = threads->list(threads::running); } sub parseLines{ open IN, '<', $_[0]; my %hash; while () { next unless ( $_ =~ m/^\@HWI/ ); my ($header) = split(/ /, $_); $hash{$header} = 1; } close IN; return \%hash; }