Skip to content

Instantly share code, notes, and snippets.

Created September 6, 2011 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1198964 to your computer and use it in GitHub Desktop.
Save anonymous/1198964 to your computer and use it in GitHub Desktop.
my $id = 'ZywYdtlIl8amEGe-Rq8xTg';
use MIME::Base64;
$id =~ tr{_-}{+/};
$id .= 'AA';
my $bin_id = decode_base64($id);
my $hex_id = unpack("H*", $bin_id);
$hex_id =~ s/0{3,4}$//;
# print $hex_id
my @parts = ($hex_id =~ m/^((.{2})(.{2}).+)/)[1,2,0];
print map "$_\n", join '/', @parts;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment