Paul said:
Please modify your script so that it produces some debugging output, is
strict- and warnings-compliant, and checks for errors with open(). If
after doing this you are still seeing an error, feel free to post your
new program here for further assistance.
I have made all the corection anyone said but it still doesn't do what i
wanted it to do(matches the $head_ with $reg ).
I didn't use your's,
open my $NWRULE, '<' 'rule.spam' or die "Could not open rule.spam: $!";
Because i got an error:
String found where operator expected at t_svm.pl line 7, near "'<'
'rule.spam'"
(Missing operator before 'rule.spam'?)
syntax error at t_svm.pl line 7, near "'<' 'rule.spam'"
Execution of t_svm.pl aborted due to compilation errors.
So I used insted:
open(DATA, "<rule.spam") || die "can't open rule.spam";
while ( my $rule = <DATA> ) {
....sniped
}
close(DATA);
Can you please make a file called rule.spam and put in it :
new_1 head Subject: .*\.\.
new_2 head Subject: Get
It's very important to use a file because i have to use it so nothing else
works for me!
Other important thing is to test it on linux/perl (it works on windows what
really pisses me off). My version of perl is 5.8.4 ( This is perl, v5.8.4
built for i386-linux-thread-multi) and the platform is debian sarge.
The whole program is :
#!/usr/bin/perl
use strict;
use warnings;
my $head_ ="Subject: Get cheap v i a g r a ..... ";
open(DATA, "<rule.spam") || die "can't open rule.spam";
while ( my $rule = <DATA> ) {
print "New rule is: $rule \n";
my ($new_id, $dio, $reg);
if ( $rule =~ /(\S+) (\S+) (.+)/ ) {
$new_id=$1;
$dio=$2;
$reg=$3;
}
print "New id is: $new_id\n";
print "New dio is: $dio\n";
print "New reg is: $reg\n";
if ( $head_ =~ m/$reg/ ) {
print "Using reg from a file\n"; # it newer matches
}
if ( $head_ =~ m/Subject: .*\.\./ ) {
print "Using written regex\n"; # it always matches
}
if ( $head_ =~ m/Subject: Get/ ) {
print "Using written regex\n"; # it always matches
}
}
close(DATA);
The output is :
New rule is: new_1 head Subject: .*\.\.
New id is: new_1
New dio is: head
New reg is: Subject: .*\.\.
Using written regex
Using written regex
New rule is: new_2 head Subject: Get
New id is: new_2
New dio is: head
New reg is: Subject: Get
Using written regex
Using written regex
Dario