Re: Binding array to pattern



Shmuel (Seymour J.) Metz wrote:
I'd like to bind an array to a pattern.

Why?

Is there a better way to do this than

$_="@anarray";
while (/pattern/g) {
block;
}

?

This is more readable IMO:

foreach my $element ( @anarray ) {
while ( $element =~ /PATTERN/g ) {
...
}
}

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.



Relevant Pages