in reply to newbie to regex: all matches

I tried the following but it makes the script hand indefinitely.
my $content = get($start); my @matches; while ($content) { push(@matches, $1) if ($content =~ m/(page.php?id=\ +d+)/)} print @matches;

Replies are listed 'Best First'.
Re^2: newbie to regex: all matches
by sulfericacid (Deacon) on Mar 10, 2006 at 01:00 UTC
    Be sure to \? before your ? as that's a special character.

    UPDATE adding code

    my @matches = ($content =~ m/(image.php\?id=\d+)/g);

    UPDATE 2 Fixed typo of /? to \? thanks to GrandFather



    "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

    sulfericacid
Re^2: newbie to regex: all matches
by duckyd (Hermit) on Mar 10, 2006 at 05:56 UTC
    This will run forever because the while loop will run as long as $content is true. Nothing in the loop changes $content, so assuming it's true to begin with, the loop never ends.