use Storable; open IN, "input.fa"; my %id2off; while () { next unless /^>/; chomp; $id2off{substr($_, 1)} = tell(IN); # file pointer points to start # of next line } store \%id2off, 'input.idx';