I have a file containing records separated by a |.
In order to classify these entries, I first split each line, and match certain fields against a hash of filters.
The filters are loaded from a configuration file at run-time.
I am thus limited to $var[5] =~ /$regex/ (or at least I think so) for my matching.
Is it possible to get something like this to work:
$re[0] = qr (.*(?!system))i;
$re[1] = qr (system)i;
$v[0] = "oneitem";
$v[1] = "anothersystem";
for $a (@v) {
for $r (@re) {
print "\nRegex: $r\tValue: $a\n";
if ($a =~ /$r/) {
print "$a matches $r\n" ;
}
}
}
As this results in:
Regex: (?-xism:.*(?!system)) Value: oneitem
oneitem matches (?-xism:.*(?!system))
Regex: (?-xism:system) Value: oneitem
Regex: (?-xism:.*(?!system)) Value: anothersystem
anothersystem matches (?-xism:.*(?!system))
Regex: (?-xism:system) Value: anothersystem
anothersystem matches (?-xism:system)
Which is not what I want...
Is it possible to construct a regex that "matches if doesn't contain" ?