JIMMY wrote:
> i have a @list that contains elements i do not know. i'm
> using grep to match some words inside the @list.
> for example:
> $match = grep /\d/, @list;
> my question is: is there a way to find the element No. eg:
> $list[number] of the latest match?
I don't think so. You'll probably have to use foreach and keep your own
counter (which works even with multiple arrays, or with lists of constants),
or use for and index over the array (which obviously only works with one,
named array). Something like this (untested):
my $count = 0;
my $lastmatch;
foreach (@list) {
$lastmatch = $count if /\d/; # your test here
$count++;
}
if (defined $lastmatch) {
print "Last match at index $lastmatch\n";
} else {
print "No match.\n";
}
Cheers,
Philip
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]