in reply to Picking certain values to convert from binary to decimal

If I understand correctly, you want to extract the three bytes starting at offset 29. You can get those with substr and then unpack them. Since your file is binary, let's read the first 32 bytes only, by setting $/ to a reference to 32.

my @chars; { local $/ = \32; open my $fh, '<', $name or die $!; binmode $fh; local $_ = <$fh>; @chars = unpack 'CCC', substr $_, 29, 3; close $fh or die $!; } print "@chars", $/; # quoted only to put space between values
The conversion is done by unpack, according to the template given in its first argument. "Decimal" really has little to do with it. The decimal string is produced by the stringification of a numeric value.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Picking certain values to convert from binary to decimal
by nadadogg (Acolyte) on Jan 08, 2004 at 14:51 UTC
    This output values similar to what I used before, and even though I found an alternate way of doing it(using some proprietary work stuff), your stuff helped me understand how to use it. Thanks a bunch.