From: yitzle <[EMAIL PROTECTED]> > On 1/18/08, bootleg86 bootleg86 <[EMAIL PROTECTED]> wrote: > > Hi, > > I can't for the life of me figure out what this is trying to do > > $token = $$ ^ unpack "%L*", `ps -A | "./bin/gzip" > > > > Just seems to be it's trying to generate some random number. > > I only know it's trying to XOR the process ID. > > > > What does this part do? > > unpack "%L*", `ps -A | "./bin/gzip" > > > > Thanks > > ps -A lists all the processes on a Unix machine. > gzip compesses its input > `ps -A | gzip` will compress the text that ps -A outputs. > I presume the zipped version of your system's processes would look > fairly random, as it got a bunch of random PIDs, times, names, etc > > http://perldoc.perl.org/functions/unpack.html > > unpack does the reverse of pack: it takes a string and expands it out into > > a list of values. > "%L*" is a "template" for unpack, whatever that means. > >From pack: "L An unsigned long value." > I guess it expands the gzip'd > string into longs, giving you a list of random longs.
You forgot the %. It causes pack to compute a checksum out of those long values instead of returning the values itself. So you get a 16bit checksum of a fairly random data and xor it with the process id. a fairly insteresting way to obtain a random number. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/