What follows is snippet out of a more complex script and reworked to
simplify but still not seeing what causes the problem.

I'm not sure if I've just stared at it too long or what.  When I run it
I get this error:

    Use of uninitialized value in pattern match (m//) at ./match.pl
    line 14.  No match here

I'm far less than skilled with the perl debugger but walking thru with
it, I tested by way or `print', if both variables have value before
the match, and of course they do.  I've looked hard for a mis-spelling
but don't see one.

Just not seeing the problem... Is it a complete misuse of `=~' ? or
what?

I realize I could forgo the qr// compilation but should that be necessary?
In the actual script its used 20-100 times on each of thousands of
files. (the program scans only the headers of mail messages)

And shouldn't the expressions match? Or does !~ signify an EXACT
match?  I understood, it signifies a regex match in which case
`Date:' should match `Date: some date'... shouldn't it?

-------        ---------       ---=---       ---------      -------- 

#!/usr/local/bin/perl

use strict;
use warnings;

my $date_re = qr/^Date:/;
my $other_re = qr/^Date: some date/;

if (/$date_re/ !~ /$other_re/){
   print "No match here\n"
}else{
   print "It's a match\n";
} 


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to