S
Shashank R Khanvilkar
Hi,
All help appreciated.
I have to parse a file which has a header. This header is say 4 bytes long
and contains many fields which are not byte aligned. For example
struct header {
#fieldname: Size(bits)
fld1: 12
fld2: 1
fld3: 2
....
}
I have already written a lengthy routing to unpack these fileds from the
header (using shifts and masks). However i was wondering if the same could
have been achieved using the pack and unpack functions?
For example:
@hdr = unpack("B12B1B2....", $header);
I find that this does not work.
Does anyone know how this can be done.
To complicate the problem fursther, how can the same be achieved for any
aribitary length header (say 15 bytes).
Thanks
Shashank
All help appreciated.
I have to parse a file which has a header. This header is say 4 bytes long
and contains many fields which are not byte aligned. For example
struct header {
#fieldname: Size(bits)
fld1: 12
fld2: 1
fld3: 2
....
}
I have already written a lengthy routing to unpack these fileds from the
header (using shifts and masks). However i was wondering if the same could
have been achieved using the pack and unpack functions?
For example:
@hdr = unpack("B12B1B2....", $header);
I find that this does not work.
Does anyone know how this can be done.
To complicate the problem fursther, how can the same be achieved for any
aribitary length header (say 15 bytes).
Thanks
Shashank