develooper Front page | perl.perl5.porters | Postings from October 1999

Re: [PATCH 5.005_62] First round of unpack

Thread Previous | Thread Next
Ilya Zakharevich
October 27, 1999 11:04
Re: [PATCH 5.005_62] First round of unpack
Message ID:
On Wed, Oct 27, 1999 at 12:41:11AM -0700, Gurusamy Sarathy wrote:
> On Wed, 27 Oct 1999 03:06:54 EDT, Ilya Zakharevich wrote:
> >To facilitate complicated data extraction, the following extensions
> >are allowed inside embedded templates:
> Sounds like the key word there is "complicated".

a) 't' and 'T' without "extensions" are in no way "complicated". 

b) The extensions may *look* complicated, but note that most of them
   will cease to be "extensions" the moment we have parens in
   TEMPLATEs: they will make sense in usual TEMPLATEs as well.

c) This leaves '/'-extension and "starts with a digit" extension.  The
   only reason for them is performance: they simplify pack() a lot.

   Moreover, they make debugging easier, since the packed strings
   become easier to read by human.  Say, packed string
   "/NtttttPPPPPPP" (here N is a digit, and ttttt is N characters
   long) when extracted with 't' template means: extract "PPPPPPP"
   using TEMPLATE 'ttttt'.  Similarly with "//dNNNtttttPPPPPPPP" (here
   d is a digit, NNN is d chars long, and ttttt is NNN chars long).

   These things are not any tiny bit more complicated that 'A/A/A'
   templates: they are handled by combinations of simple rules.

d) You react as if packed strings are manually created and designed
   for human consumption.  All that programmer are going to do is

       $packed = pack 't', \%data;
       system 'foo', $packed;

       $data = unpack 't', shift;


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About