Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!littlei!intelhf!agora!markb From: markb@agora.rain.com (Mark Biggar) Newsgroups: comp.lang.perl Subject: Re: Calculating XOR checksums? Fast splitting? Message-ID: <1991Jun4.022321.5332@agora.rain.com> Date: 4 Jun 91 02:23:21 GMT References: Organization: Open Communications Forum Lines: 21 In article gnb@bby.oz.au (Gregory N. Bond) writes: >Given a string, what is the fastest way to calculate the XOR of all >bytes? here is what I used: > > $bcc = 0; > grep ($bcc ^= $_, unpack("C" x length($sc_data), $sc_data)); try folding the string in half. Assumeing ther is a vec() in the program somewhere the following should work: $i = length($sc_data); while ($j = int(($i+1)/2)) { ($sc_data, $a) = unpack("A$j A$j", $sc_data); $sc_data ^= $a; $i = $j; } -- Perl's maternal uncle Mark Biggar markb@agora.rain.com