Strangely it does not match strings that look to me like obvious matches, it worked when I used a hash to store the mappings (key was pattern, value was mapped severity) but had to change this as processing order is important
I know I must be missing something obvious but I have gone snow blind from staring at it
The following is a reduced test case showing the problem.
#!/usr/bin/perl -w use strict; ################### Test arrays ######################## my @severity_map = ( "Error:Warning", "Warning:Minor", "Critical:Critical", "Alarm:Critical", "System Shutdown:Fatal", "System Powered Off:Fatal", "Failure:Critical", "Memory Bank Deconfigured:Warning", "Uncorrectable ECC:Fatal" ); my @description_samples = ( "Memory Bank Deconfigured", "Uncorrectable ECC", "Sticky Corrected ECC Error", "System Shutdown" ); ################### The code ######################### foreach my $description (@description_samples) { my $severity; foreach (@severity_map) { /(.*):(.*)/; my $regexp = $1; # uncomment following to see why this drives me mad # print "does $description=~/$regexp/i\n"; next unless $description =~ /$regexp/i; $severity = $2; } unless ($severity) { print "can find no severity mapping for: $description "; print "defaulting to WARNING\n"; $severity = "Warning"; } }
Please lead me on the path to enlightenment
my @severity_map = ( ["Error","Warning"], ["Warning","Minor"], ["Critical","Critical"], ["Alarm","Critical"], . . . foreach (@severity_map) { next unless $description =~ /$_->[0]/i; $severity = $_->[1]; }
In reply to obvious matching patterns don't match by Random_Walk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |