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


In reply to Re: List DB tables by McA
in thread List DB tables by homer4all

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.