tpl/lang/perl/tplfmt

25 lines
481 B
Plaintext
Raw Normal View History

2013-03-12 16:38:58 -04:00
#!/usr/bin/perl
# tplfmt
# by Troy Hanson Feb 2006
# print the format string of a tpl image file
use strict;
use warnings;
sub peek_fmt {
my $buf = shift;
die "invalid tpl file" unless ($$buf =~ /^tpl/);
return (unpack("Z*", substr($$buf,8)));
}
die "usage: $0 <file> [<file> ...]" unless (@ARGV > 0);
undef $/; # slurp
for (@ARGV) {
open TPL, "<$_" or die "can't open $_: $!";
my $tpl = <TPL>;
print "$_: ", peek_fmt(\$tpl), "\n";
close TPL;
}