# Simple Perl Question.

**URL:** <https://boards.straightdope.com/t/simple-perl-question/91221>\
**Category:** Factual Questions\
**Created:** [November 2, 2001, 11:35pm UTC](https://boards.straightdope.com/t/simple-perl-question/91221 "2001-11-02T23:35:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fandango](https://avatars.discourse-cdn.com/v4/letter/f/b5ac83/32.png) [@fandango](https://boards.straightdope.com/u/fandango)\
**Post date:** [November 2, 2001, 11:35pm UTC](https://boards.straightdope.com/t/simple-perl-question/91221/1 "2001-11-02T23:35:45Z")

</div>

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 =~ /&lt;–.\*–&gt;/)

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

---

<div class="post-metadata">

**Author:** ![fandango](https://avatars.discourse-cdn.com/v4/letter/f/b5ac83/32.png) [@fandango](https://boards.straightdope.com/u/fandango)\
**Post date:** [November 2, 2001, 11:43pm UTC](https://boards.straightdope.com/t/simple-perl-question/91221/2 "2001-11-02T23:43:57Z")

</div>

I got it…

my @commentarray = ($page =~ /(&lt;!–.\*?–&gt;)/gis)

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [November 3, 2001, 12:25am UTC](https://boards.straightdope.com/t/simple-perl-question/91221/3 "2001-11-03T00:25:16Z")

</div>

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

[Regular Expressions in Perl](http://www.crusoe.net/~jeffp/book/) by Jeff Pinyan is an excellent resource for this sort of thing.
