develooper Front page | perl.perl6.language | Postings from September 2000

Re: pack/unpack is damn unperlish. Explain them as Perl.

Thread Previous | Thread Next
From:
Chaim Frenkel
Date:
September 18, 2000 20:56
Subject:
Re: pack/unpack is damn unperlish. Explain them as Perl.
Message ID:
m3bsxldogu.fsf@csamnycln01.nyc.csam.com
>>>>> "ST" == Sam Tregar <sam@tregar.com> writes:

ST> I think you're talking about unpack() here, which I've only used once.  I
ST> think unpack() is usually replaceable by substr() or regexes.  Contrast
ST> that with pack() for which no equivalent replacement is possible, as far
ST> as I know.

Actually not. You need to do some extra nasties to get an integer
from a binary record into a perl scalar and have it be a number. If
you use substr it will be a string. Useless.

Pack takes binary data chops it into bitesize pieces so that perl can
use it correctly.

binary integers stay integers
if they are in the wrong endiness the bits get flipped properly.

un so weiter.

<chaim>
-- 
Chaim Frenkel					     Nonlinear Knowledge, Inc.
chaimf@pobox.com				               +1-718-236-0183

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About