$l1 = ( split //, $w1 )[ $intersect[ 0 ] - 1 ]; #### $l1 = substr $w1, $intersect[ 0 ] - 1, 1; #### #!/usr/bin/perl use strict; use warnings; my $re1 = qr($ARGV[0]); my $len1 = $ARGV[1]; my $re2 = qr($ARGV[2]); my $len2 = $ARGV[3]; my $offs1 = $ARGV[4] - 1; my $offs2 = $ARGV[5] - 1; my( %word1, %word2 ); open my $fh, '<', 'joshWordList.txt'; while( <$fh> ) { chomp; $_ = lc $_; if( length( $_ ) == $len1 and /$re1/ ) { my $letter = substr $_, $offs1, 1; push @{ $word1{ $letter } }, $_; } if( length( $_ ) == $len2 and /$re2/ ) { my $letter = substr $_, $offsr2, 1; push @{ $word2{ $letter } }, $_; } } close $fh; for my $letter ( keys %word1 ) { next if not exists $word2{ $letter }; print "Any of\n", map "\t$_\n", @{ $word1{ $letter } }; print "combined with any of\n", map "\t$_\n", @{ $word2{ $letter } }; }