new mask is ffff00ffff in score pos old word 57, motif, motor score mask s 000000ffff helper is mot-- .......... .......... ....r..... ....o..... ....o..... ..motif... ....a..... ....g..... ....e..... .......... - - - - - .......... .......... ....r..... ....o..... ....o..... ..mot--... ....a..... ....g..... ....e..... .......... #### sub score { my ( $bd, $hi, $pos, $old, $word ) = @_; my $len = length $word; my $mask = ( $old ^ $word ) =~ tr/\0/\xff/cr; say "in score pos old word"; say "$pos, $old, $word"; my( $hex ) = unpack( 'H*', $mask ); print "score mask s $hex\n"; ; my $helper = ( $old & ~$mask ) =~ tr/\0/-/r; say "helper is $helper"; say "$bd"; #### #!/usr/bin/perl use strict; # multiplayer upwords use warnings; use 5.016; use Path::Tiny; use Data::Dump; @ARGV or @ARGV = qw( one two three four ); # for testing ## paths and constraints my $abs = path(__FILE__)->absolute; my $path1 = Path::Tiny->cwd; my %var; #main data structure my $ref_var = \%var; $var{abs} = $abs; $var{cwd} = $path1; $ref_var = init_vars($ref_var); my ( $board, $heights ) = create_board($ref_var); my @dictwords = create_dict($ref_var); my %isword = map +( $_, 1 ), @dictwords; #dd \%isword; my @drawpile =create_draw_pile(); #dd \@drawpile; dd \$ref_var; #$var{max_tiles} * @ARGV > @drawpile and die "too many players for tiles\n"; sub init_vars { use Path::Tiny; use Data::Dump; use 5.016; use warnings; use POSIX qw(strftime); my $rvars = shift; my %vars = %$rvars; my $script = $vars{abs}; my $path1 = $vars{cwd}; my $games = "games"; my $path2 = path( $path1, $games ); say "abs is $abs"; say "path1 is $path1"; say "path2 is $path2"; print "This script will build the above path2. Proceed? (y|n)"; my $prompt = ; chomp $prompt; die unless ( $prompt eq "y" ); $vars{side} = 9; $vars{d_file} = path( "my_data", 'enable1.txt' ); $vars{ca_name} = path( "my_data", "words.11108138.$vars{side}" ); my $munge = strftime( "%d-%m-%Y-%H-%M-%S", localtime ); $munge .= ".txt"; $vars{save_file} = path( $path2, $munge )->touchpath; $vars{save_file}->append_utf8("Script executing is $script\n"); # other initializations $vars{max_tiles} = 7;and how best to create a main data structure $vars{n_1} = $vars{side} + 1; $rvars = \%vars; dd $rvars; say "exiting init"; return ($rvars); } sub create_board { use warnings; use 5.016; my $rvars = shift; my %vars = %$rvars; my $board = ( '.' x $vars{side} . "\n" ) x $vars{side}; my $heights = $board =~ tr/./0/r; return ( $board, $heights ); } sub create_dict { use warnings; use 5.016; my $rvars = shift; my %vars = %$rvars; my @dictwords; if ( -f $vars{ca_name} ) { @dictwords = split /\n/, $vars{ca_name}->slurp; system("stat $vars{ca_name}"); } else { print "caching words of max length $vars{side}\n"; @dictwords = sort { length $b <=> length $a } grep /^[a-z]{2,$vars{ $vars{max_tiles} = 7;side}}$/, split /\n/, $vars{d_file}->slurp; $vars{ca_name}->spew( join "\n", @dictwords, '' ); } return @dictwords; } sub create_draw_pile{ use List::Util qw( shuffle ); use warnings; use 5.016; my @drawpile = shuffle + # thanks to GrandFather 11108145 ('a') x 7, ('b') x 3, ('c') x 4, ('d') x 5, ('e') x 8, ('f') x 3, ('g') x 3, ('h') x 3, ('i') x 7, ('j') x 1, ('k') x 2, ('l') x 5, ('m') x 5, ('n') x 5, ('o') x 7, ('p') x 3, ('q') x 1, ('r') x 5, ('s') x 6, ('t') x 5, ('u') x 5, ('v') x 2, ('w') x 2, ('x') x 1, ('y') x 2, ('z') x 1; return @drawpile; } #### $ ./2.1.pt.pl abs is /home/bob/4.scripts/distro/2.1.pt.pl path1 is /home/bob/4.scripts/distro path2 is /home/bob/4.scripts/distro/games This script will build the above path2. Proceed? (y|n)y { abs => bless([ "/home/bob/4.scripts/distro/2.1.pt.pl", "/home/bob/4.scripts/distro/2.1.pt.pl", ], "Path::Tiny"), ca_name => bless(["my_data/words.11108138.9", "my_data/words.11108138.9"], "Path::Tiny"), cwd => bless(["/home/bob/4.scripts/distro", "/home/bob/4.scripts/distro"], "Path::Tiny"), d_file => bless(["my_data/enable1.txt", "my_data/enable1.txt"], "Path::Tiny"), max_tiles => 7, n_1 => 10, save_file => bless([ "/home/bob/4.scripts/distro/games/09-12-2019-12-51-34.txt", "/home/bob/4.scripts/distro/games/09-12-2019-12-51-34.txt", "", "/home/bob/4.scripts/distro/games/", "09-12-2019-12-51-34.txt", ], "Path::Tiny"), side => 9, } exiting init File: my_data/words.11108138.9 Size: 871513 Blocks: 1704 IO Block: 4096 regular file Device: 806h/2054d Inode: 3409780 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ bob) Gid: ( 1000/ bob) Access: 2019-12-09 12:31:54.804156635 -0800 Modify: 2019-12-06 14:11:08.392888086 -0800 Change: 2019-12-06 14:11:08.396887925 -0800 Birth: - \{ abs => bless([ "/home/bob/4.scripts/distro/2.1.pt.pl", "/home/bob/4.scripts/distro/2.1.pt.pl", ], "Path::Tiny"), ca_name => bless(["my_data/words.11108138.9", "my_data/words.11108138.9"], "Path::Tiny"), cwd => bless(["/home/bob/4.scripts/distro", "/home/bob/4.scripts/distro"], "Path::Tiny"), d_file => bless(["my_data/enable1.txt", "my_data/enable1.txt"], "Path::Tiny"), max_tiles => 7, n_1 => 10, save_file => bless([ "/home/bob/4.scripts/distro/games/09-12-2019-12-51-34.txt", "/home/bob/4.scripts/distro/games/09-12-2019-12-51-34.txt", "", "/home/bob/4.scripts/distro/games/", "09-12-2019-12-51-34.txt", ], "Path::Tiny"), side => 9, } $ #### ...(same as above until) max_tiles => 7, n_1 => 10, save_file => bless([ "/home/bob/4.scripts/distro/games/09-12-2019-13-32-58.txt", "/home/bob/4.scripts/distro/games/09-12-2019-13-32-58.txt", "", "/home/bob/4.scripts/distro/games/", "09-12-2019-13-32-58.txt", ], "Path::Tiny"), side => 9, } Use of uninitialized value in multiplication (*) at ./2.1.pt.pl line 31. $