Dear ALL,

I was doing some parsing for log file and come to this bug (i think), I add the next simple code to show you what I face:

use strict; use warnings; my $data = 'blabla;tag1=12345;blabla;'; # my $data = 'blabla;tag1=12345;blabla;tag2=99999'; # get tag1 value $data =~ m/tag1=(\d+)/g; my $tag1 = $1; # get tag2 value $data =~ m/tag2=(\d+)/g; my $tag2 = $1; print "tag1 = $tag1\n"; print "tag2 = $tag2\n";

The output:

tag1 = 12345 tag2 = 12345

Us you can see the are only tag1 value in $data, so should be no match and the second tag $tag2 should be undefined,

but what i got is  $tag1 =$tag2!!!.

So can any monk here (and pretty please) explain to my what happen here.

BR

Hosen


In reply to ambiguous regex match by Hosen1989

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.