# ... if ( $file =~ /$start_pattern(.*?)$end_pattern/s ) { print $1; } # ...