SPUG: pack and unpack

Richard Wood wildwood_players at yahoo.com
Wed Aug 27 18:03:16 CDT 2003


Right, 

Got the "Z" working on a machine with a newer version
of perl (doesn't work on was 5.004_04, does work on
5.005_03).  I only have second edition of Camel.  I
will take a look at third edition tonight.

All of my LONGs are coming out 808464432 and all of my
SHORTS are coming out 12336.  I will figure this out
sooner or later. 

Sorry I can't send a file.  They belong to a local
airplane company and I am not at liberty to transmit
them.

elsif ($type == 3) {                       # SHORT
       $decoded_value =unpack "n", $value;
    } elsif ($type == 4) {                 # LONG
       $decoded_value = unpack "N", $value;
    }

LONG    00000000000000000000000000000000 808464432
LONG    00000000000000001100100000010111 808464432
LONG    00000000000000000011000000010111 808464432
LONG    00000000000000000011000000010111 808464432
LONG    00000000100000000011100000110011 808464432
LONG    00000000000000000000000000000000 808464432
SHORT    00000000010000000000000000000000    12336
SHORT    00000000100000000000000000000000    12336
SHORT    00000000001000000000000000000000    12336
SHORT    00000000000000000000000000000000    12336
SHORT    01000000000000000000000000000000    12337
SHORT    00000000100000000000000000000000    12336
SHORT    00000000100000000000000000000000    12336

Rich Wood

--- Ben Reser <ben at reser.org> wrote:
> On Wed, Aug 27, 2003 at 03:04:31PM -0700, Richard
> Wood wrote:
> > Ben, your code is certainly cleaner and seems to
> be
> > heading me in the right direction.  I don't seem
> to be
> > getting good values out but that just requires
> more
> > thought and experimentation. (by the way did you
> mean
> > to use an "A" instead of a "Z" for ASCII?  Z is
> not a
> > meta character in pack. 
> 
> According to perldoc -f pack it is:
> Z   A null terminated (ASCIZ) string, will be null
> padded.
> 
> It's been a while since I used (un)?pack so it might
> be one of the ones
> that are only usable in pack and not unpack...
> 
> I didn't test the code I sent so I can't say for
> sure it worked.  If I
> had a sample file of what I was parsing I might get
> further...
> 
> -- 
> Ben Reser <ben at reser.org>
> http://ben.reser.org
> 
> "What upsets me is not that you lied to me, but that
> from now on I can
> no longer believe you." -- Nietzsche
>
_____________________________________________________________
> Seattle Perl Users Group Mailing List  
> POST TO: spug-list at mail.pm.org 
> http://spugwiki.perlocity.org
> ACCOUNT CONFIG:
> http://mail.pm.org/mailman/listinfo/spug-list
> MEETINGS: 3rd Tuesdays, U-District, Seattle WA
> WEB PAGE: http://www.seattleperl.org
> 


=====
Richard O. Wood
Wildwood IT Consultants, Inc.
wildwood_players at yahoo.com
425.281.1914 mobile
206.544.9885 desk

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com



More information about the spug-list mailing list