Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Convert::Morse

by PERLscienceman (Curate)
on Feb 23, 2004 at 03:30 UTC ( #331013=modulereview: print w/ replies, xml ) Need Help??

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.

Comment on Convert::Morse
Download Code
Re: Convert::Morse
by Mr. Muskrat (Abbot) 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.
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).

Back to Reviews

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: modulereview [id://331013]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2014-07-28 17:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (204 votes), past polls