my $filename = test.summary"; open (IN, "<", $filename) or die "Check the summary file. $!\n"; while (my $line = ) { chomp $line; if ($line =~/^LOCUS\s+\w+\d+\s+(\d+)\sbp/) { $gene_length = $1; } if ($line =~/^DEFINITION\s+(.*)/s) { $definition = $1; } if ($line =~/^ACCESSION\s+(.*?)\s+/) { $accession = $1; } if ($line =~ /\s+\/db_xref="GI\:(\d+)\"/) { $gi_number = $1; } if ($line =~ /\s+\/db_xref=\"GeneID\:(\d+)\"/) { $gene_id = $1; } }