Even viewing the xml version of your post (ie, the way you posted it), the code makes no sense... but first, let's check: Is this what you intended:
($IPADDR,$MACADDR,$OS,$OSDETL) = $TEXT =~ /(192\.168\.1\.[\d]+).*?([\d]2:[\d]2:[\d]2:[\d]2:[\d]2:[\d]2)/g;
but it doesn't work. It will work if I only use
@matches = ( $TEXT =~ /(192\.168\.1\.[\d]+)/g);
foreach my $val (@matches) {
print "$val\n";
But if I try to match another string in the same regular expression it fails. For example, this doesn't work:
@matches = ( $TEXT =~ /(192\.168\.1\.[\d]+).*?([\d]2:[\d]2:[\d]2:[\d]2:[\d]2:[\d]2)/g);
If that's what you tried to write, amended to close the code tags as kennethk suggested, why are you using character classes when \d would work and \d{2} might do what you want?
And not just BTW, were you specify \d+ the regex engine would any number of digits until some other character intervenes or it hits the end of the string... and .*? merely limits the number of matches to the dot (anything) to as few as possible before taking up with your [\d]2:s again.
Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
- code
- verbatim error and/or warning messages
- a coherent explanation of what "doesn't work actually means.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.