in reply to Find checksum (Linux) equivalent in Perl windows

This version builds on plain crc32, evading the suffering from immoderate buffering.

#! /usr/bin/perl use strict; use warnings; use String::CRC32; #use Digest::CRC q(crc32); use open IN => ':raw'; binmode(STDIN); # reverse bits in byte(s) my $revb = do { my @H = split //, q(084c2a6e195d3b7f); my $xlat = join "", map "\\x".$H[$_&15].$H[$_>>4], 0..255; eval qq(sub{ pop =~ tr/\\x00-\\xff/$xlat/r }); }; do { my ($crc, $len) = (0xffffffff, 0); local $/ = \32768; while (<>) { $len += length; $crc = crc32($_->$revb, $crc); last if eof; } my $zz = (pack "J<", $len) =~ s/\0*$//r; $crc = crc32($zz->$revb, $crc); $crc = unpack "V", (pack "N", $crc)->$revb; print "$crc $len $ARGV\n"; } while @ARGV;
Now if someone could golf that $revb, please?

Replies are listed 'Best First'.
Re^2: Find cksum (Linux) equivalent in Perl windows
by BrowserUk (Patriarch) on Apr 23, 2015 at 01:35 UTC
    Now if someone could golf that $revb, please?

    Try:

    sub revB{ ord pack 'b8', unpack 'B8', chr( shift ) }

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked