Please code review and...

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
... and if you have some free time, offer better solutions.

I have written a small program in Perl which reads in Oracle RMAN log
file* and parses it to human friendly format.

Do you have some free time during the weekend? Would you like to play
with parsing non-standard, mixed up and a bit difficult** log file? Or
do want to parse better than I did? Just download my Perl script from
the Launchpad site:

Or, If you use Bazaar you can also get my branch in simple way:
bzr branch lp:~scottie383/+junk/parse-rman-log

Later you can update your branch with me:
bzr push lp:~scottie383/+junk/parse-rman-log

*) In this case, the log file (output of RMAN) I put in the __DATA__
section in .pl file.

**) One of the the problem is that information to the file are not
always recorded in sequence and sometimes intertwined. For example:
Channel ch2 starting:
=A0channel ch2: starting piece 1 at 2011-05-31 02:00:06=A0
Channels ch1 and ch3 finishing before ch2:
=A0channel ch1: finished piece 1 at 2011-05-31 02:34:54
=A0channel ch3: finished piece 1 at 2011-05-31 02:46:44
And a channel ch2 finished much later:
=A0channel ch2: finished piece 1 at 2011-05-31 02:47:54

Have fun and enyoj!! :-)

P.S. Please indulgence for me - a beginner Perl programmer.

Best regards,

Re: Please code review and...

Quoted text here. Click to load it

    #!/usr/bin/perl -w
    use warnings;

Choose which kind of warnings you want, then enable only that kind.

(lexical warnings are usually the best choice)

    if ( $_ =~ /$$/ ) {

too many unnecessary squiggly lines, should be:

    if ( $_ =~ /$RMAN_RUN_CH_NAME$i/ ) {
    if ( /$RMAN_RUN_CH_NAME$i/ ) {

My other comments are nitpicks, the following one is important:

    ( $backup_compressed eq 'compressed' ) ? ($bc = 'YES') : ($bc = 'NO');

that is an abuse of the ?: operator.

the ?: operator should be used to _provide a value_, it should not
be used for flow control.

too many curvy lines too.

    $bc = $backup_compressed eq 'compressed' ? 'YES' : 'NO';

Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg0cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.

Site Timeline