It is highly encouraged to reduce your code to a simple test case that demonstrates the problem. Not just so there is less for us to read through, but also to help your solve you problem beforehand and reduce red herrings. If you had run a simple test case, as I illustrate below, you would have found that your test data and regex work just fine. So you need to look for something besides the regex.

Try running the code through the perl debugger perl -d to see where it really gets stuck at.

use strict; use warnings; use Data::Dumper; my @images; my $content = '<a href="http://www.imagebeaver.com/view.php?mode=galle +ry&g=115564&photo=1" target="_blank"><img src="http://www.imagebeaver +.com/files/images/thumb/37021412066526319.jpg" border="0"></a> <a hre +f="http://www.imagebeaver.com/view.php?mode=gallery&g=115564&photo=2" + target="_blank"><img src="http://www.imagebeaver.com/files/images/th +umb/99821412066526320.jpg" border="0"></a> <a href="http://www.imageb +eaver.com/view.php?mode=gallery&g=115564&photo=3" target="_blank"><im +g src="http://www.imagebeaver.com/files/images/thumb/6234141206652632 +1.jpg" border="0"></a> <a href="http://www.imagebeaver.com/view.php?m +ode=gallery&g=115564&photo=4" target="_blank"><img src="http://www.im +agebeaver.com/files/images/thumb/33641412066526322.jpg" border="0"></ +a> <a href="http://www.imagebeaver.com/view.php?mode=gallery&g=115564 +&photo=5" target="_blank"><img src="http://www.imagebeaver.com/files/ +images/thumb/5361412066526323.jpg" border="0"></a> <a '; push(@images, "http://www.imagebeaver.com/files/images/$1:$1") while $ +content =~ m#/files/images/thumb/([a-zA-Z0-9]+\.jpg)#g; print Dumper \@images;

grep
1)Gain XP 2)??? 3)Profit


In reply to Re: regex hangs forever by grep
in thread regex hangs forever by Anonymous Monk

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.