summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-09-19 10:19:06 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2009-09-19 10:19:06 +0200
commite24d0a2a58000f71e4cfbbf75e33c9db212baab2 (patch)
tree645fcab7ab110e872b04c957d0b6b35b1fec3de9
parent01d2852d64859d9ee97cbacfd2c912635f6c97e1 (diff)
tibtoa: Use smart match where useful
-rwxr-xr-xbin/tibtoa14
1 files changed, 5 insertions, 9 deletions
diff --git a/bin/tibtoa b/bin/tibtoa
index 61c786f..9ee9287 100755
--- a/bin/tibtoa
+++ b/bin/tibtoa
@@ -818,7 +818,7 @@ sub header_size($) {
$size->{cols} = ord(substr($header, 0x48, 1));
$size->{rows} = ord(substr($header, 0x49, 1));
}
- when(/program|string|equation/) {
+ when(['program', 'string', 'equation']) {
$size->{source} = ord(substr($header, 0x48, 1)) + 255 * ord(substr($header, 0x49, 1));
}
}
@@ -833,11 +833,6 @@ sub header_datestr($) {
return(substr(shift, 0x1d, 19));
}
-#sub char_to_digits($) {
-# my $char = shift;
-# return($char >> 4, $char & 0x0f);
-#}
-
getopts('ih', \%opts);
$file = shift;
@@ -883,7 +878,7 @@ if ($opts{h}) {
# And now, the actual file content
-if ($header{type} eq 'program' or $header{type} eq 'equation') {
+if ($header{type} ~~ ['program', 'equation']) {
while($offset < $length) {
$char = ord(substr($program, $offset++, 1));
if (exists($all{$char})) {
@@ -918,7 +913,7 @@ if ($header{type} eq 'program' or $header{type} eq 'equation') {
}
}
print "$cache\n";
-} elsif ($header{type} =~ /^(matrix|list|var|zoom|window)$/) {
+} elsif ($header{type} ~~ ['matrix', 'list', 'var', 'zoom', 'window']) {
my ($exp, $digit);
my $i = 0;
my @values;
@@ -971,7 +966,8 @@ if ($header{type} eq 'program' or $header{type} eq 'equation') {
}
print "\n";
} else {
- print STDERR "file type not supported\n";
+ print STDERR "file type $header{type} not supported\n";
+ exit 1;
}
__END__