foreach $id (keys %id2seq){ # here the last good possibility to cut $id: my $filename = (split /\|/, $id)[0]; ...