I would just have used map to make that a lot more simple:
print map { "$_|" } @my_list
And a design pattern that you should start to recognize is that as soon as you see the concatenation operator, you should be thinking about changing that to a list. So
$my_id_list .= $my_list[$i]."|";
should change to
push ( @my_id, "$my_list[$i]|" );
Later, after you're done with the loop, you can
join all of the list elements together.
And if your code also removes the last "|" from the strong that you're building, then you can do
push ( @my_id, $my_list[$i] );
during the loop and
join('|',@my_id);
at the end of the loop to get the same result.
Alex / talexb / Toronto
"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds