Bug: unpack in scalar context 
Author Message
 Bug: unpack in scalar context

According to the Camel book, unpack in a scalar context unpacks a
single value.   In fact, it returns the format string if the format
string starts with an x specifier.

% perl -v

This is perl, version 4.0

$RCSfile: perl.c,v $$Revision: 4.0.1.4 $$Date: 91/06/10 01:23:07 $
Patch level: 10

Copyright (c) 1989, 1990, 1991, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 4.0 source kit.

% perl -e '$_="012345XY98765"; $m = unpack("x6 a2", $_); print $m;'
x6 a2

% perl -e '$_="012345XY98765"; ($m) = unpack("x6 a2", $_); print $m;'
XY

% perl -e '$_="012345XY98765"; $m = unpack("a2", $_); print $m;'
01

hmmmmmm.....
--
Gregory Bond, Burdett Buckeridge & Young Ltd, Melbourne, Australia

Uucp: {uunet,pyramid,ubc-cs,ukc,mcvax,prlb2,nttlab...}!munnari!melba.bby.oz!gnb



Tue, 29 Mar 1994 13:10:21 GMT  
 Bug: unpack in scalar context

+---------------
| According to the Camel book, unpack in a scalar context unpacks a
| single value.   In fact, it returns the format string if the format
| string starts with an x specifier.
+---------------

Thank you.  I thought I was either (a) going crazy or (b) unearthed Yet
Another SCO Unix Bug.  (Lord knows I've tickled enough of them so far....)

++Brandon
--
Brandon S. Allbery                    KF8NH: DC to LIGHT!  [44.70.4.88]



Thu, 31 Mar 1994 02:59:07 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. unpack in scalar context

2. perl5.000 bug: array/scalar context screwed up

3. slices in scalar context - bug or feature?

4. array context versus scalar context

5. PERLFUNC: scalar - force a scalar context

6. PERLFUNC: scalar - force a scalar context

7. should scalar unpack yield the template?

8. Minimizing an unpacked scalars length()?

9. .. in scalar context doc change

10. scalar vs. list context in function calling arguments

11. Return value of a list in scalar context

12. File input in scalar/array context

 

 
Powered by phpBB® Forum Software