Problems? Is your data what you think it is? | |
PerlMonks |
A regex question.by FeistyLemur (Acolyte) |
on Jul 31, 2015 at 21:49 UTC ( [id://1137070]=perlquestion: print w/replies, xml ) | Need Help?? |
FeistyLemur has asked for the wisdom of the Perl Monks concerning the following question: This is my first post here, I have a question about something I can't explain. I'm pretty sure I know what I did wrong, I'm just not 100% sure why it was wrong and wanted to clarify to better my understanding of regex in perl, as I'm fairly inexperienced and looking to improve. I was searching for vlan ids for removal in the output of "ip addr" in the following way.
Doing this as above mostly worked, but it would always miss the first entry for no reason I can explain. So if there were 25 vlan entries in the string from 1001 to 1025 it would match and delete 1002-1025 without fail, and miss 1001 every time. Changing line 2 to: if ($ethernet!~/eth1\.\d{4}\@/){Does what I intended to do. I had the same problem with a similar line I was using to scrub IP addresses off the vlan devices again missing the first match, I just don't understand why the while loop breaks in the way it does because of the /gm flag on the preceeding if statements match, and was hoping someone could explain. Thanks in advance.
Back to
Seekers of Perl Wisdom
|
|