Thanks for the input, I now have something that works. Using ord was very helpful, I have also modified it to use sysopen and sysseek, for some reason using sysread with the offset parameter doesn't work for me hence the sysseek. As for using CRCs, I know the checksum is weak but I have just been tasked to automate an existing process, not to change the process so I don't get to choose the method. I will look at the modulo arithmetic approach to see if I can get that working rather than the mess of packing and unpacking.
sub Checksum { my @Arguments = @_ ; my $Start = $Arguments[0] ; my $Size = $Arguments[1] ; my $FileName = $Arguments[2] ; my $FileHandle ; unless ( sysopen $FileHandle, $FileName, 0 ) { die "\nsysopen failed"; } my $BufferByte = 0 ; my $Checksum = 0 ; my $ChecksumLoopCounter = 0 ; my $ChecksumByteOffset = $Start ; unless ( sysseek($FileHandle, $Start, 0) == $Start ) { die "\nsysseek error" ; } while ( $ChecksumLoopCounter < $Size ) { unless ( sysread ( $FileHandle, $BufferByte, 1) == 1 ) { die "sysread size error" ; } my $Byte = ord($BufferByte); $Checksum = unpack("S" , pack("S", $Checksum + $Byte)); $ChecksumLoopCounter++ ; $ChecksumByteOffset++ ; } close $FileHandle ; return $Checksum; }

In reply to Re: Accessing individual bytes of a binary file as numerical values by Chris01234
in thread Accessing individual bytes of a binary file as numerical values by Chris01234

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.