my $search; if ($cmdout =~ / \n ( .* procdump .*) \n /sx) { $search = $1; print "$search\n"; }