in reply to find the element position of $scalar

Here's a few quick bits of code.

Indexed iteration:
foreach my $i (0..$#array) { print "$i: $array[$i]\n"; }
Regular iteration with incremented tracker:
my $i = 0; foreach my $e (@array) { print "$i: $e\n"; $i++; }
Old-school C-style method:
for (my $i = 0; $i < @array; $i++) { print "$i: $e\n"; }
In this case, I'd say the first is "better" since it requires less code.