S
sonet
I am tesing the code from
http://perl.apache.org/docs/general/perl_reference/perl_reference.html#Compiled_Regular_Expressions .
But it seem have some problem ,and i can not slove it by myself.
Sometime ,I got the result "Use of uninitialized value in concatenation (.)
or string at (eval 1) line 1, <HANDLE> line 101."
#you can got notspam.lst FROM
http://se2.program.com.tw/Portal_images/notspam.lst
#!/usr/local/perl
use warnings;
my $i = 0;
my $nsi = 0;
my @test;
open( HANDLE, 'notspam.lst' );
while (<HANDLE>)
{
$_ =~ s/\r|\n| //g;
if ( $_ ne '' && $_ !~ m/\#/ )
{
$test[ $nsi++ ] = $_;
}
}
close(HANDLE);
my $result = expr_build(@test);
open( HANDLE, 'notspam.lst' );
while (<HANDLE>)
{
$_ =~ s/\r|\n| //g;
if ( $_ ne '' && $_ !~ m/\#/ )
{
if ( !&$result("$_") )
{
print $_ . '=>no' . "\n";
sleep(5);
} else
{
print $_ . '=>yes' . "\n";
}
}
}
sub expr_build
{
my @R = @_;
my $expr = join '||', map { "\$_[0]=~/\$R[$_]/oi" } ( 0 .. $#R );
my $subref = eval "sub { $expr }";
return $subref;
}
http://perl.apache.org/docs/general/perl_reference/perl_reference.html#Compiled_Regular_Expressions .
But it seem have some problem ,and i can not slove it by myself.
Sometime ,I got the result "Use of uninitialized value in concatenation (.)
or string at (eval 1) line 1, <HANDLE> line 101."
#you can got notspam.lst FROM
http://se2.program.com.tw/Portal_images/notspam.lst
#!/usr/local/perl
use warnings;
my $i = 0;
my $nsi = 0;
my @test;
open( HANDLE, 'notspam.lst' );
while (<HANDLE>)
{
$_ =~ s/\r|\n| //g;
if ( $_ ne '' && $_ !~ m/\#/ )
{
$test[ $nsi++ ] = $_;
}
}
close(HANDLE);
my $result = expr_build(@test);
open( HANDLE, 'notspam.lst' );
while (<HANDLE>)
{
$_ =~ s/\r|\n| //g;
if ( $_ ne '' && $_ !~ m/\#/ )
{
if ( !&$result("$_") )
{
print $_ . '=>no' . "\n";
sleep(5);
} else
{
print $_ . '=>yes' . "\n";
}
}
}
sub expr_build
{
my @R = @_;
my $expr = join '||', map { "\$_[0]=~/\$R[$_]/oi" } ( 0 .. $#R );
my $subref = eval "sub { $expr }";
return $subref;
}