http://qs1969.pair.com?node_id=331013

Item Description:

Review Synopsis: Package to convert between ASCII text and MORSE alphabet.

CPAN LINK: Convert::Morse
CPAN ABSTRACT: Package to convert between ASCII text and MORSE alphabet.
Introduction:
This module caught my eye as yet another 'Cool Use For Perl', appealing to both the avid Perl Programmer and Amateur Radio Hobbyist inside me.
Functionality:
In a nutshell, Convert::Morse converts an ascii string to equivalent International Morse Code dots and dashs and visa-versa. In addition, the module contains a function to check and see if a particular ascii string "is morsable", convertable to a valid morse code string.
Demo Code:

#!/usr/bin/perl use strict; use Convert::Morse qw(as_ascii as_morse is_morsable); print as_ascii('.... . .-.. .-.. --- -- --- .-. ... .'),"\n"; # 'Hell +o Morse' print as_morse('Perl?'),"\n"; # '.--. . .-. .-.. ..--.. +' print "Yes!\n" if is_morsable('Hello Perl.'); # print "Yes!"
Bug(s) Found:
None immediately found with preliminary testing.
Module Author Noted Limitation:
Can not yet do Japanese code nor German Umlaute.

Final Thoughts:
With further tinkering I found this module to be quite useful in converting English text to valid dot-dash-spaces International Morse Code; indeed another Cool Use For Perl for both die-hard those who are both Die-Hard Perl Programmers and Radio Enthusiasts alike.
UPDATE:There is indeed only one International Morse Code recognized by International Treaty that does not include japanese or umlaute character sets; Thanks to theorbtwo for pointing that out.

Replies are listed 'Best First'.
Re: Convert::Morse
by theorbtwo (Prior) on Feb 23, 2004 at 07:48 UTC

    Uh, there is only one true morse code, and it doesn't include japanese, umlaute, or even an exlemation point.

    And I say not that because of standards-worship, but because morse code is what it is by international treaty, and (at least as I understand it), if you don't know that, you can't use the approprate bands. IOW, if you send "überrhacking" in morse over a frequency where morse or voice is allowed, you're in violation of the treaty, since that isn't morse. Similarly, if, on your code test, you are asked to encode "übergeschloss", the correct answer is "it can't be done in morse", or morse("uebergeschloss").


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: Convert::Morse
by Mr. Muskrat (Canon) on Feb 23, 2004 at 03:40 UTC
      Drats! I dragged this module out of it's coma (from 2001!) a few weeks ago to fix a bug with ")" and "(" in morse, only to forget about "@" :-( Oh well. About International Morse Code: Quite a few people obviously use their own encoding for their characters, like the Japanese, or the German Umlaute. (Convert Morse also does contain more than the regular characters). This dilemma could be solved with a "strict" mode. Maybe the module should finally be made OO. Tels Btw: The link to the "@" is dead.