Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jan Kasprzak
tinyboard
Commits
26400646
Commit
26400646
authored
May 12, 2013
by
Jan Kasprzak
Browse files
morse.pl: morse code to binary char arrays generator
parent
ccfee457
Changes
1
Hide whitespace changes
Inline
Side-by-side
projects/step-up/morse.pl
0 → 100755
View file @
26400646
#!/usr/bin/perl -w
my
$code
=
shift
@ARGV
;
$code
=~
s/\./10000/g
;
$code
=~
s/-/1110000/g
;
$code
=~
s/\//000000/g
;
my
$ones
=
(
$code
=~
y/1/1/
);
my
$len
=
length
$code
;
if
(
$len
%
8
!=
0
)
{
$code
.=
'
0
'
x
(
8
-
(
$len
%
8
));
}
$code
=~
s/(.{8})/\t0b$1,\n/g
;
my
$ratio
=
sprintf
('
%.1f
',
100
*$ones
/
$len
);
print
"
\t
/*
$len
bits,
$ratio
\
% on */
\n
",
$code
;
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment