in reply to Determine first element in foreach
Before you enter the loop you set my $first=1 and in the if-branch you do $first=0 to switch it off.
HTH! :)
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)