Oracle DRM Blog

06 Aug, 2008

Perl Gem

Posted by: Daniel In: Perl

Have you ever walk across a junkyard, maybe it’s for cars, maybe it’s just a dump…probably not huh…and you pick up a thing or two. Heaven forbid you land on a Picasso or something, wouldn’t that be great? Come a little closer to life, maybe you’re a BMW enthusiast, and you walk in a showroom with the latest BMW gears, how are you gonna feel? Not too bad I hope. Well that kind of experience happened to me today as I browse through the web and came across a block of code.

I’ve been doing Perl for over 12 years now, and this code blew me away… This is just an extremely clever piece of code, I salute to the original author of his work because it’s genius. Sorry I won’t tell you what it does because you probably won’t appreciate it. If you know a bit about Perl, then you can read through it and please make a comment on this blog on what your guesses are.

use strict;
use warnings;
use Compress::Zlib;
++$|;
open IN, ‘test.exe’ or die $!;
binmode IN;
read IN, my $data, 1e8;
my $piecenum=0;
my $progress = progress(length $data);
my $piecedata;
for (0..length($data)-1) {
$progress->($_);
$piecedata = uncompress(”\x78\x9c” . substr $data, $_);
if (defined $piecedata) {
print “\nPiece at $_\n”;
open OUT, sprintf(’>piece_%03d.txt’, $piecenum++) or die $!; binmode OUT;
print OUT $piecedata ^ chr(0xAA) x length $piecedata;
}
}
sub progress {
my $max = $_[0];
my $last = 0;
return sub { print $last = int(100*$_[0]/$max), “%… ” if $last != int(100*$_[0]/$max) };
}

Sorry, I apologize if I just wrote a blog post about nothing to you…

Visitors who read this post, also read:



Tags:

No Responses to "Perl Gem"

Comment Form


  • Daniel: Ravi, yes there're a couple of properties needed for Essbase. If you are using v11 DRM, you should have the templates available already. Just check it
  • Daniel: Hi Tonia, use 9.3.1 add-in and it'll work fine unless you absolutely need version 11 features. In that case, we maybe able to help offline. Regards,
  • Daniel: There isn't any documentation as such from version 8. The DRM database structure is very different, you will have to rebuild it. Shouldn't be too hard

About This Blog

My name is Daniel Poon. I am a multi-disciplined business intelligence professional with a strong dynamic career leading Financial Processes, People, BI Systems and Global Projects to accomplishments. Known for passion in implementing process excellence, quality BI solutions and creative innovations. Thanks for visiting my special interest blog.

 Subscribe This Blog For Free Now

Disclaimer: The words, ideas and opinions here are my own. Please don't assume they represent the opinion of my employer, any other person or organization. Do read the Terms of Use. If you would like to quote me, please ask me first or provide a link back.