Here's what I did in Perl, I stumbled upon this question when I was looking for a more elegant way to do this (so far with no luck).
use strict; use warnings; my $guid; if (shift() =~ /\{([0-9A-F\-]+)\}/) { $guid = $1; } die "Usage $0: <guid>\n" unless $guid; my @sections = split /-/, $guid; die "Malformed guid $guid\n" if @sections != 5; my $str; for (my $i = 0; $i < 3; ++$i) { $str .= reverse($sections[$i]); } my @tmp = split //, join('', @sections[3,4]); for(my $i = 0; $i < @tmp; $i += 2) { $str .= join('', @tmp[$i+1, $i]); } print "$str\n";
source share