#!/usr/bin/perl # https://perlmonks.org/?node_id=11104709 use strict; use warnings; use List::Util qw( none ); use Path::Tiny; my @words = # get some words grep /^fun/, # for shorter testing grep /^[a-z]+$/, path('/usr/share/dict/words')->lines({chomp => 1}); my @longs = grep length $_ >= 9, @words; # all legal long words for my $short ( grep length $_ <= 8, @words ) # all legal short words { for my $long ( grep /$short/, @longs ) # all long superstrings { if( none { # test for word between length $_ > length $short and length $_ < length $long and $long =~ $_} @words ) { print "$long $short\n"; } } } #### funicular fun funniness fun functional function functionaries function functionary function functioned function functioning function functions function fundamental fund fundraiser fund fundraising fund funereally funereal fungicidal fungi fungicide fungi fungibles fungible funkiness funk funneling funnel