SPUG: Re: unpack
Yitzchak Scott-Thoennes
sthoenna at efn.org
Sun Mar 17 03:37:54 CST 2002
In article <005c01c1cbee$79883870$1c88ddd1 at aciwin>,
"Richard Anderson" <richard at richard-anderson.org> wrote:
>Not 100% certain, but it looks like you forgot to account for the null
>terminator on the string. $len=length($alpha)-4; gives you the length of
>the string + 1 for the null terminator. Try $len=length($alpha)-5.
>
>(Somewhat relevant aside: using hard-coded values for system-dependent
>values like the length of a long is not very portable. It's better to use a
>variable for magic numbers like this, and document what it represents. Even
>better, have your C code calculate this with the sizeof operator, write it
>to the data file and read this value for use by your Perl code.)
This is available in the %Config::Config hash:
~ $perl -MConfig -wle'print $Config{longsize}'
4
Also there are:
~ $perl -V:.*size
charsize='1'
d_chsize='undef'
doublesize='8'
fpossize='4'
gidsize='2'
i16size='2'
i32size='4'
i64size='8'
i8size='1'
intsize='4'
ivsize='4'
longdblsize='12'
longlongsize='8'
longsize='4'
lseeksize='4'
nvsize='8'
ptrsize='4'
shortsize='2'
sizesize='4'
u16size='2'
u32size='4'
u64size='8'
u8size='1'
uidsize='2'
uvsize='4'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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://seattleperl.org
More information about the spug-list
mailing list