http://www.perlmonks.org?node_id=712392

Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:

All,
I am pretty sure this question has been asked before but my Super Search fu is weak.

The Dictionary:

Use the official '2of12inf.txt' file from here stripped of all non-alpha characters and forced to lowercase.

while (<$dict_fh>) { $_ = lc($_); tr/a-z//cd; # ... }

The Input:

The code should accept a file name as a command line argument. The file will contain a list of strings, one on each line. The string needs to be forced to lowercase with all non-alpha characters removed like the dictionary above.

penisland howareyou

The Output:

For each line of input, the code should output all possible substrings (separated by whitespace) with the following constraints:

Example:

penisland

pen island penis land pen is land penis l land pen is l and

For a somewhat similar challenge, see One for the weekend: challenge. Note: The example above was done by hand and could possibly not include all possibilities.

Cheers - L~R

Update: Clarified constraint two thanks to /msg from ikegami
Update: Clarified example thanks to /msg from blokhead and ikegami