home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!elroy.jpl.nasa.gov!sdd.hp.com!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!network.ucsd.edu!nic!netlabs!lwall
- From: lwall@netlabs.com (Larry Wall)
- Newsgroups: comp.lang.perl
- Subject: Re: *Another* embarrassingly simple question
- Message-ID: <1992Jul23.190259.9652@netlabs.com>
- Date: 23 Jul 92 19:02:59 GMT
- References: <21982@venera.isi.edu>
- Sender: news@netlabs.com
- Organization: NetLabs, Inc.
- Lines: 39
- Nntp-Posting-Host: scalpel.netlabs.com
-
- In article <21982@venera.isi.edu> sondeen@isi.edu (Jeff Sondeen) writes:
- : By the way, I found some type of problem tring to use vec's.
- :
- : #! /local/bin/perl
- :
- : $num = 5;
- : for $bits (1..20) {
- : vec($numv, 0, $bits) = $num;
- : @num = reverse(split(//,unpack("b$bits", $numv)));
- : $line = join('',@num);
- : print "$line\n";
- : }
- :
- : gives:
- :
- : 1
- : 01
- : 101
- : 0101
- : 00101
- : 000101
- : 0000101
- : 00000101
- : 000000101
- : 0000000101
- : 00000000101
- : 000000000101
- : 0000000000101
- : 00000000000101
- : 000000000000101
- : 0000010100000000 ## what happend here????
- : 00000010100000000
- : 000000010100000000
- : 0000000010100000000
- : 00000000010100000000
-
- vec() is only intended to work with $bits of 1, 2, 4, 8, 16, or 32.
-
- Larry
-