FAQ
Something like this:
while(<DATA>){
     if(/d/){
         print;
         say $.;
     }
}

__DATA__
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z

Cheers,
Jing
On 9 Aug 2013, at 01:05, Unknown User wrote:


Hello,


If i am iterating through the elements in an array, at any point is it possible to say which element i am handling without using a counter? Are there any builtins that i can use for it?

ie
foreach my $element (a..z) {
...
if ( i am the 5th element ) { handle me special }

}

Thanks,

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 8 of 16 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedAug 8, '13 at 5:06p
activeAug 15, '13 at 5:27p
posts16
users9
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase