foreach my $i (0 .. $#mylist) { say "first element" if ( $i == 0 ); }