my $word = 'sigma'; my $re = join '|' => map join( '.*?' => map quotemeta, @$_) => map [ substr( $word, 0, $_), substr( $word, $_)] => 1 .. length( $word) - 1; foreach my $text ( 'sigma', 'stigma', 'silly gamma', 'magma', ) { print("$text ", ($text =~ $re ? "matches" : "doesn't match"), "\n"); } #### map { [ $word =~ /(.{$_})(.*)/] } 1 .. length( $word) - 1; #### map { ++ pos; [ split /\G/] } ( $word) x ( length( $word) - 1);