#!/usr/bin/perl use warnings; use strict; sub load_fasta { my ($file) = @_; open my $IN, '<', $file or die $!; my ($seq, $id, %hash) = q(); my $store = sub { $hash{$id} = $seq if $id; ($id) = shift =~ /\|(.*)/; $seq = q(); }; while (<$IN>) { chomp; if (/^>/) { $store->($_); } else { $seq .= $_; } } $store->(q()); return %hash } my %hash1 = load_fasta('acids.txt'); my %hash2 = load_fasta('nucleotides.txt');