SPUG: Not reading to end of binary file on the PC

Jay Scherrer jay at Scherrer.com
Mon May 7 23:30:50 CDT 2001


I have been using  the stable win32 binary version of Perl 5.4 instead of
activestate for this reason. So far my although simple parsing works from one
machine to another, but I've found them to be totally compatible. Even when I
use Perl::Tk. I wish they would update that dist. to Perl 5.6.

Jay




"Cheryl Tornquist (Seattle)" wrote:

> Hi all,
>
> I have a chance to prove the usefulness of PERL in my new company, but I'm
> stumped on a problem and hope someone else may know the answer.  I've
> written several successful PERL scripts for other companies but cannot find
> anything to solve this one in the Camel book, the O'reilly cookbook,
> Learning Perl on Win32, Perl for System Administration, the online docs or
> several other sources.  I'm already using binmode.
>
> The script reads a proprietary binary file and gets different results
> between a sun/solaris environment (PERL ver. 5.6.0) and Windows 2000
> environment (ActiveState build 522 and build 623).  The code works perfectly
> on the Unix box (reads in all the file and formats it to a text file) but
> only part of the binary log file is read when using Win2000 (the required
> OS).  A section of relevant pseudo code is below.  When running on the PC,
> the script reads the 12 fixed bytes until the last line which returns only
> 11 bytes.  This is when it encounts the hex code 001a 4e00 for the first
> time on all three sample files.  001a are the 11th and 12 bytes.  read()
> returns up to and including the first 00 (ASCII NULL) but doesn't read the
> 1a as it should (ASCII substitute -- what does a substitute do?).
>
> What is happening here and how do I get the script to read the whole file on
> the Windows platform?
>
> Help is greatly appreciated.
>
> Cheryl Tornquist
> Oracle Developer
> Dotcast, Inc.
>
> #!/usr/bin/perl
> open (LOGENTRY, "< $binlog") or die "Can't open file $binlog -- $!.\n";
> binmode (LOGENTRY);
> $template = "H8 B32 B16 B16";
> undef $/;
> while (read LOGENTRY, $logentry, 12) {   # read in the whole file and
> process
>    unpack
>    read the rest of the entry
>    write to text file
> }
> close LOGENTRY;
>
>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>      POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
>       Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
>   Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
>  For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
>   Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list