CAD-Format-STL
view release on metacpan or search on metacpan
lib/CAD/Format/STL.pm view on Meta::CPAN
# now, detection...
$mode = sub {
my $fh = shift;
seek($fh, 80, 0);
my $count = eval {
my $buf; read($fh, $buf, 4) or die;
unpack('L', $buf);
};
$@ and return 'ascii'; # if we hit eof, it can't be binary
$count or die "detection failed - no facets?";
my $size = (stat($fh))[7];
# calculate the expected file size
my $expect =
+ 80 # header
+ 4 # count
+ $count * (
+ 4 # normal, pt,pt,pt (vectors)
* 4 # bytes per value
* 3 # values per vector
+ 2 # the trailing 'short'
);
( run in 1.382 second using v1.01-cache-2.11-cpan-49f99fa48dc )