I want to generate a list of unique IDs. Because some of the IDs are duplicates, I need to add a number at the end to make them unique, like so:
ID=exon00001
ID=exon00002
ID=exon00003
ID=exon00004
Here's what I have so far.
while (loop through the IDs) {
# if $id is an exon, then increment the counter by one and add it
# to the end of the ID
if ($id =~ m/exon/) {
my $exon_count = 0;
my @exon = $exon_count++; #3
$number = pop @exon; # removes the first element of the list
$id = $id.$number;
print $id."/n"
}
}
Basically I want to dynamically generate an array with a counter. It's supposed to create an array (1, 2, 3, 4, ... ) for the total number of exons, then remove the elements and add it to the string. This code doesn't work properly. I think there's something wrong with line #3. Do you guys know? Any ideas? thank you
$exon_countis reset each time a new exon is found, you assign a single value (always 0, because ++ is evaluated afterwards) to an array,popremoves the last element of an array, and"/n"will print a slash andn, if you want newline, you'd need"\n".shiftremoves the first element from the list,popremoves the last--however it does remove the "top" element of a stack, but that's a stack, not a list.