Ramprasad wrote:
>
> I have an array of regular exps of which I want to match any of them
> in a string. How can I do this without eval.
>
> for eg.
>
> @array = (
> '/^to: myprog/mi',
> '/^from: [EMAIL PROTECTED]/mi'
> );
>
> $STRING = read_mail_header(...);
>
>
> foreach (@array) {
>
Hi,
Why don't you do like that :
@array = (
'^to: myprog',
'^from: [EMAIL PROTECTED]'
);
$STRING = read_mail_header(...);
foreach (@array) {
if($STRING=~ /$_/mi ) { # This should work
# FOUND
.
}
}
or
Rob Dixon wrote:
Ramprasad wrote:
I have an array of regular exps of which I want to match any of them
in a string. How can I do this without eval.
for eg.
@array = (
'/^to: myprog/mi',
'/^from: [EMAIL PROTECTED]/mi'
);
$STRING = read_mail_header(...);
foreach (@array) {
if($STRING=~
Ramprasad wrote:
>
> This was not cut pasted from my actual code. I cannot paste my 250
> line script here so I just wrote a hapazard relevant replica of what
> I did.
Fair enough! An even worse problem is where people's company standards
prohibit decent coding, but I always bear in mind that what