my $text1 = qq{
text tex text more text
}; my $text2 = qq{
text text text more text
}; my $regex = '
(.*)(.*)
'; if ( $text1 =~ /$regex/sg ) { warn "Text 1 found ".$1.$3; } if ( $text2 =~ /$regex/sg ) { warn "Text 2 found ".$1.$3; }