Last active
September 1, 2023 05:32
-
-
Save tallpeak/eb8f20f91ff326631111d9530d2e75fb to your computer and use it in GitHub Desktop.
morse code to ascii
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ASCII 32 to 95, where "" means undefined | |
@morse = (' ', '-.-.--', '.-..-.', '', '...-..-', '', '.-...', '.----.', '-.--.', '-.--.-', '', | |
'.-.-.', '--..--', '-....-', '.-.-.-', '-..-.', '-----', '.----', '..---', '...--', | |
'....-', '.....', '-....', '--...', '---..', '----.', '---...', '-.-.-.', '', '-...-', | |
'', '..--..', '.--.-.', '.-', '-...', '-.-.', '-..', '.', '..-.', '--.', '....', '..', | |
'.---', '-.-', '.-..', '--', '-.', '---', '.--.', '--.-', '.-.', '...', '-', '..-', | |
'...-', '.--', '-..-', '-.--', '--..', '', '', '', '', '..--.-'); | |
$ascii = 32; | |
for $m(@morse) { | |
$ch = chr($ascii++); | |
$morseAscii{$m}=$ch; | |
} | |
$message = "... --- ..."; | |
# for $w(split(" ",$message)) { | |
# print($morseAscii{$w}); | |
# } | |
$message =~ s/([.-]{1,7})/$morseAscii{$1}/g; | |
$message =~ tr/ //d; | |
print($message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment