Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

frayoyo's scratchpad

by frayoyo (Monk)
on Mar 15, 2007 at 08:09 UTC ( #604940=scratchpad: print w/replies, xml ) Need Help??

Morse-Code (mst, 2001.08.23)
perl -e'map{($a=substr(sprintf("%b",$n+++2),1))=~tr/01/.-/;print"$_= $ +a\n"}split(//, "etianmsurwdkgohvflpjbxcyzqch",30)'
oder / or / ou / a
Braille-Code
perl -e'map{$pos=/W/?39:ord()-65-/[X-Z]/;($z=join "",reverse split //, +sprintf "%.6b",@{[0,16,48,32]}[int $pos/10]+hex(@{[split(//,"153B97FD +6E")]}[$pos%10]))=~ s/(..)/\n$1/g;$z=~tr/01/.O/;printf "%s\n%s\n\n",$ +_,$z}@{[A..Z]}'
(dt/en/fr/eo) Hier die Braille Ausgabe / This presents us following braille-signs / C'est la prochaine Braille-text / rigardu Braille-tekston:
A O. .. .. B O. O. .. C OO .. .. D OO .O .. E O. .O .. F OO O. .. G OO OO .. H O. OO .. I .O O. .. J .O OO .. K O. .. O. L O. O. O. M OO .. O. N OO .O O. O O. .O O. P OO O. O. Q OO OO O. R O. OO O. S .O O. O. T .O OO O. U O. .. OO V O. O. OO W .O OO .O X OO .. OO Y OO .O OO Z O. .O OO
Der letztere "Einzeiler" in Python / Transfer of last oneliner to python / C'est en Python / traduke en Python:
#!/usr/bin/python20 ''' Braille-Applikation ''' class Braille: ''' Brailleklasse Synopsis: sys.path.append("h:\\sc\\Python") import braille m = braille.Braille() m.str2br("Hallo Welt") ''' def __init__(self): ''' Anlegen Klassenbezeichner ''' import string self.code = "8ACD9EFB67" self.sgn = {} self.sgn["w"] = ".OOO.O" self.sgn[" "] = "......" #Fehlt: Leertaste for i in range(26): if i <> 22: # "w" = 22 letter = string.letters[i] r = self.itob(int(self.code[i%10],16)) r = r + self.itob((0,2,3)[int(i/10)]+4)[1:] self.sgn[letter] = r def itob(self,i, b = "", chars=".O"): ''' Binaerumwandlung ''' while i > 0: b = chars[i%2] + b i /= 2 return b def str2br(self, txt=""): ''' Wandle Text in Braillezeichen um ''' import re for i in txt.lower(): print i # insert linebreak after every 2nd sign print re.sub("(..)","\g<1>\n", self.sgn[i])+"\n",
Und jetzt die Morsezeichen in Python / Now let's try it in Python / Morse-signees per Python / Ni provas gxin en Python:
#!C:/python20/bin/python.exe class Morse: ''' Morseklasse Synopsis: m = Morse() m.str2mrs("Hallo Welt") ''' def __init__(self): ''' Anlegen Klassenbezeichner ''' self.code = "etianmsurwdkgohvflpjbxcyzq" self.sgn = {} self.sgn["ch"] = "----" self.sgn[" "] = " " #Fehlt: Leertaste for i in self.code: self.sgn[i] = self.itob(self.code.find(i)+2) self.sgn[i] = self.sgn[i].replace("0", ".") self.sgn[i] = self.sgn[i].replace("1", "-") self.sgn[i] = self.sgn[i][1:] def itob(self,i, b = ""): ''' Binaerumwandlung ''' while i > 0: b = `i%2` + b i /= 2 return b def str2mrs(self, txt=""): ''' Wandle Text in Morsezeichen um ''' for i in txt.lower(): print self.sgn[i],
Ausgabe der Morsezeichen / Display of Morsesigns:
Ausgabe: e= . t= - i= .. a= .- n= -. m= -- s= ... u= ..- r= .-. w= .-- d= -.. k= -.- g= --. o= --- h= .... v= ...- f= ..-. = ..-- l= .-.. = .-.- p= .--. j= .--- b= -... x= -..- c= -.-. y= -.-- z= --.. q= --.- = ---. ch= ----
Oder sortiert nach Buchstaben / sorted by letters / c'est assortie / preni en vico:
perl -e'map{($a=substr(sprintf("%b",$n+++2),1))=~tr/01/.-/;push @ar,"$ +_= $a\n"}split(//, "etianmsurwdkgohvflpjbxcyzqch",30);map {print} +sort @ar'
Ausgabe:
a= .- b= -... c= -.-. ch= ---- d= -.. e= . f= ..-. g= --. h= .... i= .. j= .--- k= -.- l= .-.. m= -- n= -. o= --- p= .--. q= --.- r= .-. s= ... t= - u= ..- v= ...- w= .-- x= -..- y= -.-- z= --.. = .-.- = ---. = ..--
Parser:
perl -e'map{($a=substr(sprintf("%b",$n+++2),1))=~tr/01/.-/;$h{$_}=$a}s +plit(//,"etianmsurwdkgohvflpjbxcyzqch",30);map {print $h{lc $_}." +"} split //,$ARGV[0];print "\n"' Hallo Du da
Ausgabe / Display / voir ici / speco
.... .- .-.. .-.. ---
Krachmacher / outburst / musique / adi:
perl -e"map {print;select undef,undef,undef,0.25} (qq(\a\a), qq(\a), q +q(\a\a))"
Ausgabe: - . (g)   (Abstand der einzelnen Zeichen: sec durch select undef,undef,undef,.25)
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2017-11-19 13:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (281 votes). Check out past polls.

    Notices?