tplfmt 481 B

123456789101112131415161718192021222324
  1. #!/usr/bin/perl
  2. # tplfmt
  3. # by Troy Hanson Feb 2006
  4. # print the format string of a tpl image file
  5. use strict;
  6. use warnings;
  7. sub peek_fmt {
  8. my $buf = shift;
  9. die "invalid tpl file" unless ($$buf =~ /^tpl/);
  10. return (unpack("Z*", substr($$buf,8)));
  11. }
  12. die "usage: $0 <file> [<file> ...]" unless (@ARGV > 0);
  13. undef $/; # slurp
  14. for (@ARGV) {
  15. open TPL, "<$_" or die "can't open $_: $!";
  16. my $tpl = <TPL>;
  17. print "$_: ", peek_fmt(\$tpl), "\n";
  18. close TPL;
  19. }