Don't know if this is more Perlish, but this also seems to give the same results, also produces 'null' zeroth elements:
use strict;
use warnings;
my $string =
"BEHACJBDLCENADFEGOFHQAGIHJRBIKJLSCKMLNTDMOFNPOQTGPRIQSKRTMPS";
my @result = (
[ 0, 0, 0, 0, ],
# map [ 0, map $_ -= 64, unpack 'C*', $_ ], # -= is pointless
map [ 0, map $_ - 64, unpack 'C*', $_ ],
unpack '(a3)*', $string
);
# Print the results
for my $i (1..20) {
for my $j (1..3) {
print sprintf("%02d", $result[$i][$j]) . " ";
}
print "\n";
}
Output:
02 05 08
01 03 10
02 04 12
03 05 14
01 04 06
05 07 15
06 08 17
01 07 09
08 10 18
02 09 11
10 12 19
03 11 13
12 14 20
04 13 15
06 14 16
15 17 20
07 16 18
09 17 19
11 18 20
13 16 19
Update: $_ -= 64 in
map statement is pointless waste of computrons. Changed to
$_ - 64 per
oshalla's reply
below.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.