Word search: Difference between revisions

m
→‎{{header|Perl}}: future-proof for 5.36, use new bitwise string operators
m (syntax highlighting fixup automation)
m (→‎{{header|Perl}}: future-proof for 5.36, use new bitwise string operators)
Line 2,431:
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">#!/usr/bin/perluse strict;
 
use strict; # http://www.rosettacode.org/wiki/Word_search
use warnings;
use feature <bitwise>;
use Path::Tiny;
use List::Util qw( shuffle );
Line 2,471 ⟶ 2,470:
}
substr $_, $pos, length $mask,
(substr( $_, $pos, length $mask ) &. ~. "$mask") |. "$expand";
push @played, join ' ', $word, $start, $end;
tr/.// > 0 or last;
Line 2,506 ⟶ 2,505:
while( /(?=(.(?:$gap.){$nm1}))/g )
{
my $pat = ($1 &. $mask) =~ tr/\0//dr;
$pat =~ tr/.// or next;
my $pos = "$-[1] $+[1]";
2,392

edits