Extracting GUIDs from a bunch of text

As part of messing with Windows Performance Recorder profiles, I had a need to extract everything that looks like a GUID from a blob of text. So I wrote this script. It digs through its STDIN and outputs all the GUID-looking things, uppercase-ized and sorted. https://github.com/mvaneerde/blog/blob/master/scripts/extract-guids.pl

1

Perl scripts to encrypting and decrypt text using Rijndael

I talked about Rijndael in a few previous posts: Expressing a function f: GF(2⁸) → GF(2⁸) as a polynomial using a Lagrange polynomial, Generating the Rijndael S-box, Efficient multiplication and division in GF(28), Sieving irreducible monic polynomials over a finite field, Addition and multiplication table for GF(22). Today I wrote a couple of Perl scripts…

0

Sieving irreducible monic polynomials over a finite field

Last time we talked about the addition and multiplication tables for GF(2²); GF(28) is relevant for the Rijndael encryption scheme. Joan Daemen and Vincent Rijmen use a representation of GF(28) where each element is a polynomial of the form b7x7 + b6x6 + b5x5 + b4x4 + b3x3 + b2x2 + b1x + b0, with the…

1

Perl script to parse MPEG audio header

I’ve written a perl script (attached) which will parse MPEG audio headers and display them in a human-readable format. For example, if you run it on ding.mpeg (also attached) you get this output: >perl mpegaudioheader.pl ding.mpeg Frame header: 11111111 111 (should be all ones) MPEG Audio version ID: 11 (MPEG version 1 (ISO/IEC 11172-3)) Layer…

1

Perl one-liner: approximate pi via Monte Carlo method

http://programmingpraxis.com/2009/10/09/calculating-pi/ >perl -e”print 4/(map{$n+=rand()**2+rand()**2<1}1..pop)*$n” 5000 3.1336 59 characters, plus arguments.

0

Bad Perl: locker problem

Bad Perl solution to the “print the open lockers” problem: perl -e”print join’, ‘,map{$_*$_}1..sqrt pop” 100 54 characters.  I prefer this to the 53-character solution obtained by omitting the space after the first comma. EDIT: 49 characters: perl -e”print map{$_*$_,’ ‘}1..sqrt pop” 100 EDIT: 48: perl -e”print map{$_*$_.$/}1..sqrt pop” 100 EDIT: 47: perl -e”map{print$/.$_*$_}1..sqrt pop”…

0

Bad Perl: Josephus problem

Another programming contest asks to solve the Josephus problem. Bad Perl solution (83 characters… so close…) >perl -e”@_=(1..$ARGV[0]);++$c%$ARGV[1]?$i++:splice@_,$i%=@_,1while$#_;print@_” 40 328 EDIT: got it down to 80. >perl -e”@_=(1..shift);++$c%$ARGV[0]?$i++:splice@_,$i%=@_,1while$#_;print@_” 40 328 EDIT2: 78 dropping the parentheses. >perl -e”@_=1..shift;++$c%$ARGV[0]?$i++:splice@_,$i%=@_,1while$#_;print@_” 40 328 EDIT3: 66, shamelessly cannibalizing others’ ideas from the contest (though I refuse to use “say”) >perl…

1

Bad Perl: Russian Peasant multiplication algorithm

I found this programming contest interesting: here’s what I’ve got. perl -e “($a,$b)=@ARGV;map{$c+=$_*$b}grep{$a&$_}map{1<<$_}(0..log($a)/log 2);print$c” 7 19 I’m calling this a one-liner because the part between the quotes is less than 80 characters (75, to be exact.)  The full command line goes over :-( Requires the inputs to be positive whole numbers. Perfect example of Bad…

1

Good Perl, Bad Perl

One of my favorite languages is Perl.  Perl has an ambivalent reputation; some people take to it, some accuse it of being a syntax-complete language.  (There’s some truth to this.) My view is that Perl gives you a very direct link into the mind of the programmer – much more so than other languages.  Perl…

0