Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!shelby!portia.stanford.edu!stergios From: stergios@portia.Stanford.EDU (stergios marinopoulos) Newsgroups: comp.lang.perl Subject: vec(expr,offset,bits) Message-ID: Date: 10 Aug 90 19:07:35 GMT Sender: news@portia.Stanford.EDU (USENET News System) Reply-To: stergios@jessica.stanford.edu Organization: AIR, Stanford University Lines: 31 can someone explain the behavior of vec to me? I've been playing with the example below, followed by its output. I understand the first line of output when the offset is 0; the value printed is from the i-th bit to the first.. When I give a nonzero offset, however, I dont quite understand whats happening. What is the offset applied to, the string or the bitfield? thanks sm ********************************************************************** $string = sprintf ("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", 255,255,255,255, 255,255,255,255, 255,255,255,255, 255,255,255,255 ); foreach $j (0,1,2,3) { for($i=1 ; $i <= 8 ; $i++) { printf "%5d ", vec($string,$j,$i) ; } print "\n" ; } ********************************************************************** 1 3 7 15 31 63 127 255 1 3 7 15 7 3 1 255 1 3 3 15 31 15 3 255 1 3 7 15 1 63 7 255 **********************************************************************