# Rejected possibility one: substr( $string, 0, length( $string ) / 2 ) =~ m/pattern/; # Rejected possibility two: my $half = length( $string ) / 2; $string =~ m/pattern.{$half}/s;