Re: Binding array to pattern
- From: "Shmuel (Seymour J.) Metz" <spamtrap@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 09 Jun 2006 16:25:56 -0300
In <4erq9dF1ge4orU1@xxxxxxxxxxxxxx>, on 06/09/2006
at 01:30 AM, Gunnar Hjalmarsson <noreply@xxxxxxxxx> said:
Shmuel (Seymour J.) Metz wrote:
I'd like to bind an array to a pattern.
Why?
I want to test for a match anywhere in the array.
This is more readable IMO:
foreach my $element ( @anarray ) {
while ( $element =~ /PATTERN/g ) {
...
}
}
I had simplified my code because I was primarily concerned with the
endless loop rather than style. What I actually wound up with[1] was
foreach (sort keys %{$host_info{$host}{Email}}) {
push @Contacts, @{$host_info{$host}{Email}{$_}};
my $scalarContacts="@{$host_info{$host}{Email}{$_}}";
push @abuseContacts, @{$host_info{$host}{Email}{$_}}
if (/abuse/ or $scalarContacts =~ /abuse/);
}
and I'd rather avoid replicating the push statement. Given that, is
there a better style?
Thanks.
[1] The code is quck and dirty and at some point I intend to
do some massive cleanup, but it's still a work in progress.
--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>
Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spamtrap@xxxxxxxxxxxxxxxxxx
.
- Follow-Ups:
- Re: Binding array to pattern
- From: Uri Guttman
- Re: Binding array to pattern
- References:
- Binding array to pattern
- From: Shmuel (Seymour J.) Metz
- Re: Binding array to pattern
- From: Gunnar Hjalmarsson
- Binding array to pattern
- Prev by Date: Re: creating log file
- Next by Date: Re: Binding array to pattern
- Previous by thread: Re: Binding array to pattern
- Next by thread: Re: Binding array to pattern
- Index(es):
Relevant Pages
|
Loading