Simple Perl Question.

I have an entire web page in variable $page, I want to get out all the comments into a list. What is the pattern I need to match?

I tried

my @commentarray = ($page =~ /<–.*–>/)

but that returns the whole page, not just the comments.

I got it…

my @commentarray = ($page =~ /(<!–.*?–>)/gis)

Making it non-greedy makes all the difference, dunnit? :slight_smile:

Regular Expressions in Perl by Jeff Pinyan is an excellent resource for this sort of thing.