#!/usr/bin/perl use warnings; use strict; while (){ print "Match on line $. with []\n" if (/[htm|asp]/); print "Match on line $. with ()\n" if (/(htm|asp)/); } __DATA__ optout.htm optout.asp optout.php OUTPUT: Match on line 1 with [] Match on line 1 with () Match on line 2 with [] Match on line 2 with () Match on line 3 with []