Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!spool.mu.edu!uunet!mcsun!ukc!ox-prg!bush From: bush@ecs.ox.ac.uk (Mark Bush) Newsgroups: comp.lang.perl Subject: Re: First impressions of new perl user (code, questions, ...) Message-ID: <1495@culhua.prg.ox.ac.uk> Date: 25 Mar 91 17:01:55 GMT References: <126310@uunet.UU.NET> Sender: news@prg.ox.ac.uk Organization: Oxford University Computing Laboratory Lines: 45 In article <126310@uunet.UU.NET> rbj@uunet.UU.NET (Root Boy Jim) writes: >In article mayer@sono.uucp (Ronald &) writes: >?A random idea (not really a request; just something I was thinking about): >? >?In the unpack function do "A" and "a" mean the same thing? > >Obviously not. > >?If not, are the differences documented (not in my man page). But the man page *does* document the difference (and a very useful difference it is, too! >To be honest, I couldn't quote you the exact differences, >chapter and verse. From the man page: " pack(TEMPLATE,LIST) Takes an array or list of values and packs it into a binary structure, returning the string containing the structure. The TEMPLATE is a sequence of char- acters that give the order and type of values, as follows: A An ascii string, will be space padded. a An ascii string, will be null padded." so: $a = pack("a4", "ab"); $b = pack("A4", "ab"); print "a is <$a>, b is <$b>\n"; printf "length(a) = %d, length(b) = %d\n", length($a), length($b); will produce: a is , b is length(a) = 4, length(b) = 4 print pack("A5", "Just"), pack("A8", "another"), pack("A5", "Perl"), pack("A7", "hacker,"); Mark