Skip to content

Commit

Permalink
simplify hexout.pl to use wrap.pl's format
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Laire committed Mar 28, 2012
1 parent 5cd36ea commit 57389ec
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions hexout.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/perl
use v5.12;
use warnings FATAL => 'all';
use strict;

Expand Down Expand Up @@ -28,24 +29,11 @@
my $s = $groove_size{$c};
for my $l (($full ? 1 : 2) .. 3) {
for (1 .. $s-$l+1) {
my %ps = map { $p{$c . $_} => 1 } $_ .. $_+$l-1;
my $name = $c . join "", $_ .. $_+$l-1;
$rows{$name} = join " ", map { $ps{$_} // 0 } @points;
$rows{$name} = [map $p{$c . $_}, $_ .. $_+$l-1];
}
}
}

if ($mode eq 'gen') {
print scalar(@points) . " 0 \n";
print "$rows{$_}\n" for sort keys %rows;
}
elsif ($mode eq 'decode') {
my @row_names = sort keys %rows;
while (<STDIN>) {
print join(" ", map $row_names[$_] // $_, grep /\S/, split /\s+/) . "\n";
}
}
else {
print "unknown mode: $mode\n";
exit 1;
}
say join " ", @points;
say join " ", $_, @{$rows{$_}} for keys %rows;

0 comments on commit 57389ec

Please sign in to comment.