#!/usr/local/bin/perl5.6.0 use strict; my $index_of_item; my $item = q{d}; for ( qw| a b c d e f g | ) { ( $_ eq $item ) ? last : $index_of_item++; } print qq{Index of [$item] is [$index_of_item]\n};