in reply to List DB tables

Hi,

your script is not complete as some functions are missing and there are some typos which will cause a failure.

Anyway some hints:

1. Put a use warnings; below use strict;.

2. Call your functions simply with func(bla);, forget the ampersand in front of the function name.

3. Please format your code consequently. (indent, spaces)

4. The natural flow of your script could be: connect to db, call function which returns list of object (you can print complex data structures with Data::Dumper), if the list has at least one entry call a function which produces text from the list ( a kind of formatter function), if list is not empty take the generated text and put it to an emailing function.

Answer first question: Mail only when returned list of objects is not empty.

Second question:

sub putHeader { my $db_name = shift; my $header = qq{ $db_name ============== OWNER Table Created }; return $header }

Third question:

open my $fh, '|-', 'mailx -s "List report" test@mail' or die "ERROR: C +ouldn't open pipe: $!"; print $fh $generatedMailText or die "ERROR: Couldn't write to pipe: $! +"; close $fh or die "ERROR: Closing pipe failed: $!";

Best regards
McA

Replies are listed 'Best First'.
Re^2: List DB tables
by homer4all (Acolyte) on Mar 08, 2013 at 21:56 UTC
    thanks McA...

    your comments really helped and I was able to get rid of .ksh file and get sendmail part into perl..

    but my current problem is log file contents doesn't gets email only name of file appear in email body part... so what exactly I shoul write for $generatedMailText is it

    $outputFile or log.list_tables

    $outputFile = log.list_tables
    open my $fh, '|-', 'mailx -s "List report" test@mail' or die "ERROR: C +ouldn't open pipe: $!";
    print $fh $generatedMailText or die "ERROR: Couldn't write to pipe: $! +";
    close $fh or die "ERROR: Closing pipe failed: $!";
    Thanks, homer