i just ran into a really weird problem that i can't seem to sort out and i was wondering if someone could take a look at it and tell me if i'm doing something obviously wrong.
the following script works as expected. all of the patterns that i have stored as scalars are matching correctly.
Code:
use strict;
use warnings;
my $kobolds = '^#(broken|over|pox|s(elan|l(a|i)ve|pider)|the)|(a_)?glooming';
my $spiders = '^#venom|a_gloom(_|f)';
my $rats = '^#r(at|uf)|a_(cave|diseased)_r';
my @kobold_list = (
'#Brokenclaw',
'#Overlord Gnikan',
'#Pox',
'#Selandoor',
'#Slavemaster Ruga',
'#Sliver',
'#Spider_Tamer_Gugan',
'#The_Gloomingdeep_Locksmith',
'a_garroted_kobold',
'a_Gloomingdeep_captain',
'a_Gloomingdeep_grunt',
'a_Gloomingdeep_plaguebearer',
'a_Gloomingdeep_slave_warden',
'a_Gloomingdeep_spiritweaver',
'a_Gloomingdeep_warrior',
'Gloomingdeep_Spiritweaver',
'Gloomingdeep_Taskmaster',
'a_kobold_barrel'
);
foreach my $npc (@kobold_list) {
if ( $npc =~ m/$kobolds/i ) {
print "MATCHED: $npc\n";
}
else {
print "NOT MATCHED: $npc\n";
}
}
print "\n";
my @spider_list = (
'#Queen_Gloomfang',
'#Venomfang',
'a_gloom_spider',
'a_gloom_spiderling',
'a_gloomfang_luker',
'a_small_spider'
);
foreach my $npc (@spider_list) {
if ( $npc =~ m/$spiders/i ) {
print "MATCHED: $npc\n";
}
else {
print "NOT MATCHED: $npc\n";
}
}
print "\n";
my @rat_list = (
'#Ratasaurus',
'#Rufus',
'a_cave_rat',
'a_diseased_rat',
'a_small_rat'
);
print "\n";
foreach my $npc (@rat_list) {
if ( $npc =~ m/$rats/i ) {
print "MATCHED: $npc\n";
}
else {
print "NOT MATCHED: $npc\n";
}
}
running it results in the following output:
(for some reason an extra newline is printed after the final $npc in @spider_list)
Code:
C:\EQEmu\sandbox>perl test_matches.pl
MATCHED: #Brokenclaw
MATCHED: #Overlord Gnikan
MATCHED: #Pox
MATCHED: #Selandoor
MATCHED: #Slavemaster Ruga
MATCHED: #Sliver
MATCHED: #Spider_Tamer_Gugan
MATCHED: #The_Gloomingdeep_Locksmith
NOT MATCHED: a_garroted_kobold
MATCHED: a_Gloomingdeep_captain
MATCHED: a_Gloomingdeep_grunt
MATCHED: a_Gloomingdeep_plaguebearer
MATCHED: a_Gloomingdeep_slave_warden
MATCHED: a_Gloomingdeep_spiritweaver
MATCHED: a_Gloomingdeep_warrior
MATCHED: Gloomingdeep_Spiritweaver
MATCHED: Gloomingdeep_Taskmaster
NOT MATCHED: a_kobold_barrel
NOT MATCHED: #Queen_Gloomfang
MATCHED: #Venomfang
MATCHED: a_gloom_spider
MATCHED: a_gloom_spiderling
MATCHED: a_gloomfang_luker
NOT MATCHED: a_small_spider
MATCHED: #Ratasaurus
MATCHED: #Rufus
MATCHED: a_cave_rat
MATCHED: a_diseased_rat
NOT MATCHED: a_small_rat
the moment i add a comment anywhere in the script, nothing beneath that line will execute. i've tried escaping the # symbols in the patterns and everything else i could possibly think of, all to no avail.
i'm at a loss here... any ideas?