#!/usr/bin/perl @MORSE_VALUES = (".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", "-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----."); #$morse_message = "-.--....--.-.------.----....-...----------.-.-.--.--....----....--..-.-.-.-."; #$morse_message = ".-.-.-.-..--....----....--.--.-.-.----------...-....----.------.-.--....--.-"; #$morse_message = "-.-.-.-.--..----....----..-..-.-.-..........---.----....-......-.-..----..-."; $morse_message = ".-..----..-.-......-....----.---..........-.-.-..-..----....----..--.-.-.-.-"; open(WORDS, "words"); @words = ; close(WORDS); chomp(@words); @words = (@words); foreach $w (@words) { $w = uc($w); foreach $x (@words){ $x = uc($x); foreach $y (@words){ $y = uc($y); $mw = convertToMorse($w.$x.$y); if (index($morse_message, $mw) != -1) { print "$mw "."$w "."$x "."$y\n"; } } } } sub convertToMorse { local($str) = @_; $morse = ""; for($i=0;$i 64 && $ascii < 91) { $morse .= $MORSE_VALUES[$ascii - 65]; } elsif ($ascii > 47 && $ascii < 58) { $morse .= $MORSE_VALUES[$ascii - 48 + 26]; } } return $morse; }