home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!cs.utexas.edu!torn!nott!bnrgate!bcars664!leibniz!walt
- From: walt@bcarh1d7.bnr.ca (Walt Sullivan)
- Newsgroups: comp.lang.perl
- Subject: unpack() limitation/bug?
- Message-ID: <WALT.92Dec18165612@bcarh1d7.bnr.ca>
- Date: 18 Dec 92 21:56:12 GMT
- Sender: news@bcars664.bnr.ca
- Distribution: world
- Organization: Bell-Northern Research, Ottawa, Canada
- Lines: 99
-
- It seems that I can't unpack() more than 9 fields. Can this be true?
- Here's the script that shows the problem:
-
- ------------------------------ Cut here ------------------------------
- #!/usr/bin/perl
- @templates = (" @0 A5"," @6 A15"," @22 A4"," @27 A12"," @40 A2"," @43 A2"," @46 A8"," @55 A6"," @62 A15"," @78 A12"," @91 A5"," @97 A8"," @106 A15"," @122 A12");
- $line = "AAAAA BBBBBBBB CCCC DDDDDDDD EE FF GGGGGGGG HHHH IIIIIIIII JJJJJJJJJJJJ KKKKKKKK LLLLL ";
- print "Perl version $]\n";
- print "line length = ", length($line),"\n";
- print "line=/$line/\n";
- foreach $template ( @templates ) {
- print "$template produces /", unpack($template, $line), "/\n";
- }
- print "See, each one works. Now we'll use several\n\n";
-
- $grow = "";
- foreach $template( @templates) {
- $grow .= $template;
- print "template=/",$grow,"/\nunpack =/";
- (@result) = unpack($grow, $line);
- print join("/",@result),"/\n";
- }
- exit(0);
- ------------------------------ Cut here ------------------------------
-
- And here's what I get, using Perl 4.0, pl 19 on HP-UX 8.0 on a 9000/360.
- I get the same result using Perl 4.0 pl 19 on a Sun Sparc I, SunOS 4.1.1:
-
- ------------------------------ Cut here ------------------------------
- Script started on Fri Dec 18 16:27:00 1992
- bcarh1d7-61> uname -a
- HP-UX bcarh1d7 B.08.00 A 9000/360 080009016376
- bcarh1d7-62> perl -v
-
- This is perl, version 4.0
-
- $RCSfile: perl.c,v $$Revision: 4.0.1.6 $$Date: 91/11/11 16:38:45 $
- Patch level: 19
-
- 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.
- bcarh1d7-63> perl perl.bug
- Perl version $RCSfile: perl.c,v $$Revision: 4.0.1.6 $$Date: 91/11/11 16:38:45 $
- Patch level: 19
-
- line length = 137
- line=/AAAAA BBBBBBBB CCCC DDDDDDDD EE FF GGGGGGGG HHHH IIIIIIIII JJJJJJJJJJJJ KKKKKKKK LLLLL /
- @0 A5 produces /AAAAA/
- @6 A15 produces /BBBBBBBB/
- @22 A4 produces /CCCC/
- @27 A12 produces /DDDDDDDD/
- @40 A2 produces /EE/
- @43 A2 produces /FF/
- @46 A8 produces /GGGGGGGG/
- @55 A6 produces /HHHH/
- @62 A15 produces /IIIIIIIII/
- @78 A12 produces /JJJJJJJJJJJJ/
- @91 A5 produces //
- @97 A8 produces //
- @106 A15 produces /KKKKKKKK/
- @122 A12 produces /LLLLL/
- See, each one works. Now we'll use several
-
- template=/ @0 A5/
- unpack =/AAAAA/
- template=/ @0 A5 @6 A15/
- unpack =/AAAAA/BBBBBBBB/
- template=/ @0 A5 @6 A15 @22 A4/
- unpack =/AAAAA/BBBBBBBB/CCCC/
- template=/ @0 A5 @6 A15 @22 A4 @27 A12/
- unpack =/AAAAA/BBBBBBBB/CCCC/DDDDDDDD/
- template=/ @0 A5 @6 A15 @22 A4 @27 A12 @40 A2/
- unpack =/AAAAA/BBBBBBBB/CCCC/DDDDDDDD/EE/
- template=/ @0 A5 @6 A15 @22 A4 @27 A12 @40 A2 @43 A2/
- unpack =/AAAAA/BBBBBBBB/CCCC/DDDDDDDD/EE/FF/
- template=/ @0 A5 @6 A15 @22 A4 @27 A12 @40 A2 @43 A2 @46 A8/
- unpack =/AAAAA/BBBBBBBB/CCCC/DDDDDDDD/EE/FF/GGGGGGGG/
- template=/ @0 A5 @6 A15 @22 A4 @27 A12 @40 A2 @43 A2 @46 A8 @55 A6/
- unpack =/AAAAA/BBBBBBBB/CCCC/DDDDDDDD/EE/FF/GGGGGGGG/HHHH/
- template=/ @0 A5 @6 A15 @22 A4 @27 A12 @40 A2 @43 A2 @46 A8 @55 A6 @62 A15/
- unpack =/AAAAA/BBBBBBBB/CCCC/DDDDDDDD/EE/FF/GGGGGGGG/HHHH/IIIIIIIII/
- template=/ @0 A5 @6 A15 @22 A4 @27 A12 @40 A2 @43 A2 @46 A8 @55 A6 @62 A15 @78 A12/
- unpack =/@ outside of string at perl.bug line 16.
- bcarh1d7-64>
- script done on Fri Dec 18 16:27:21 1992
- ------------------------------ Cut here ------------------------------
-
- Help!
-
- Walt
-
-
- --
- Walt Sullivan
- INTERNET: walt@bnr.ca (work)
- UUCP: walt@orbit.ocunix.on.ca (home)
- FIDO: 1:163/109.4
-