in reply to reg exp question
Since no one seems to have mentioned it so far...
The basic problem here is greedy matching. The ".*" is a greedy match so "m%(<a href="http://dynamodata.*/a>)%g" will match exactly once, with ".*" matching everything between the first occurrence of "<a href="http://dynamodata" and the last occurrence of "/a>". If, as in this case, you want to match the first following occurrence of "/a>" you can use the non-greedy form ".*?". So,
The basic problem here is greedy matching. The ".*" is a greedy match so "m%(<a href="http://dynamodata.*/a>)%g" will match exactly once, with ".*" matching everything between the first occurrence of "<a href="http://dynamodata" and the last occurrence of "/a>". If, as in this case, you want to match the first following occurrence of "/a>" you can use the non-greedy form ".*?". So,
should work (not tested, since I'm not at the right machine at the moment....)@tags = $content =~ m%(<a href="http://dynamodata.*?/a>)%g;
|
---|
In Section
Seekers of Perl Wisdom