{ open my $foo, '<', \$web or die $!; while (<$foo>) { if (m/(log_id\=(\d*)\&.*?Label Defect)/m) { #... etc } } }