open (FILE, "<$some_file") or die "Error: $!\n"; while () { next if !~ m[$pattern]; print "Hey, I found \$1: $1 \$2: $2 \$3: $3\n"; } close FILE;