Hi,
Below script reads a log file (which contains a list of id's) and selects the same Data from the log file with the Oracle tables. Can someone help how to extent the script in a way that : when selecting /reading if it finds unmatched id's it has to send an email with the Body of the email as:

log: 17
Database: 16
list of not found id :
id1
id2

#!user/local/bin/perl use strict; use warnings; use DBI; my $dir = '/usr/home/Scripts/Test'; # get the text files from the specified dir opendir DIR, $dir or die "could not open directory $dir: $!"; my @files = grep /\.txt$/, readdir DIR; closedir DIR; my $dbh = DBI->connect("dbi:Oracle:****", "****", "*****" ) || die( $DBI::errstr . "\n" ); $db->{AutoCommit} = 0; $db->{RaiseError} = 1; $db->{ora_check_sql} = 0; $db->{RowCacheSize} = 16; foreach my $fil (@files) { # read the ids from the files open IN, "$dir/$fil" or die "could not read $fil: $!"; #my @ids = map { chomp; "'$_'" } <IN>; my @ids = map { "'$_'" } map { chomp; split /\s+/ } <IN>; print "checking ", scalar(@ids), " ids from $fil\n"; print"@ids\n\n"; my $sel=$db->prepare("select (number||'/'||id) as List_ID from Info wh +ere List_ID in (" . join(', ', @ids) . ')'); $sel->execute(); while(my $subref = $SEL->fetchrow_hashref()) { my $list=$subref->{'LIST_ID'}; print "$list\n"; }

In reply to Printing Data to Email body from Perl by Anonymous Monk

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.