#!/usr/bin/perl use strict; use warnings; my @arr = qw(eens zwo dra); my $i= 0; foreach(@arr) { /zwo/ and do print $i."\n"; $i++; }