# find initial file $file = shift(@ARGV); # parse the initial file parse_file($file); exit 0; # read binary sprite table file and write text equivalent sub parse_file { local($file) = @_; print STDERR "reading $file:\n"; # open the binary file for read open(FILE, "<", $file) or die "Can't open $file\n"; binmode(FILE); printf("# NAME............................ TEXTURE. U.... V.... W.... H.... FLAGS.....\n"); $/ = \52; while () { # read file line my($name, $texture, $u, $v, $du, $dv, $flags) = unpack("A32A8SSSSL", $_); printf( "%-34.34s %-8.8s %5d %5d %5d %5d 0x%08x\n", "\"" . $name . "\"", $texture, $u, $v, $du, $dv, $flags); } # close the file close(FILE); }