in reply to Re^3: 3 capture multi line regex
in thread 3 capture multi line regex

Hi.

Your regex matched fine the first time but I need to put all occurences into an array. I can't get the array to hold anything now

push (@results, "$1::$2::$3"), $result_content =~ m/$regex/;
I tried adding /g to the end but it doesn't contain anything at all. I tried adding /g to the regex itself but it errors out.

What am I doign wrong?

Replies are listed 'Best First'.
Re^5: 3 capture multi line regex
by Ieronim (Friar) on Jun 30, 2006 at 21:40 UTC
    your code does a very strange thing: you AT FIRST put a string "$1::$2::$3" into array and then perform search!

    Use a cycle :)

    push (@results, "$1::$2::$3") while $result_content =~ /$regex/g;
    or a cleaner but IMO more ugly code:
    while ($result_content =~ /$regex/g) { push (@results, "$1::$2::$3"); }
      I was told recently that doing a while on the var with the HTML code can create endless loops and it's a bad thing though.