I am sending the email to the [EMAIL PROTECTED] and I am sending to you also as this is urgent. Using your previous help I can able to solve my problems.

sorry.


I am having following code and this prints the report in following format


sender: xyz.abc
department: xxx
branch: yyy
--------------------------------------------------------
receiver                    sent
-------------------------------------------------------
4423432432                  2003-09-09 09:09:00
65465466546                 2003-08-06 01:10:10
---------------------------------------------------------
Total Cost:


etc


I am having sender,receiver,sent these fields from mysql and department and branch it is from text file

the format of text file is

uid:department:branch
xyz.abc:xxx:yyy

I am taking sender field from mysql the format of sender field is
xyz abc <[EMAIL PROTECTED]>

from above I am taking part after < sign and before @ sgin ie xyz.abc
and comparing it with text file. if this found then the program take department and branch and prin the report as given in above format.



I want to calculate total cost ie count the receiver and multiply this count by Rs.1 ie in above example total receivers are 2 therefore the total cost is Rs.2


how to do this taks in the following code.



#!/usr/bin/perl -w




$!=1; use strict; use DBI; ######################################################### # Add in your variable names here ######################################################### my $db_name='smsd'; my $db_host='10.100.208.254'; my $db_user='vaishali'; my $db_pass='sms123'; my $table_name='sms_log'; my $file_name='ldap1.txt'; #########################################################


# open ldap1 text file and chunk the elements into a hash open(F,'<'.$file_name) or die "Can't open $file_name: $!\n"; my @file=<F>; close(F); my %lp1;


#while(@_=split(/\s+:\s+/,<R>)) #while(@_=split(/\s*:\s*/,<R>))


for my $file (@file) { chomp($file); my @lp1=(split(/:/,$file)); $lp1{$lp1[0]}{'uid'}=$lp1[0]; $lp1{$lp1[0]}{'department'}=$lp1[1]; $lp1{$lp1[0]}{'branch'}=$lp1[2]; }


undef @file;



# Pull the data from the MySQL database
my $dbh=DBI->connect
("dbi:mysql:$db_name:$db_host",$db_user,$db_pass)
or die "Could not connect to $db_name: $DBI::errstr";
my $query=qq~
SELECT sender,receiver,sent FROM $table_name group by sender,receiver,sent~;
my $sth=$dbh->prepare($query);
$sth->execute
or die "Could not execute to $query: $DBI::errstr";
my %seen=();
my $header=
('-' x 58).$/.
q~receiver sent ~.$/.
('-' x 58).$/;
# Now compare MySQL returns to lpad1 set



while (my $row=$sth->fetchrow_arrayref()) {





(my $temp_sender1=$row->[0])=~s/^.*?<|[EMAIL PROTECTED]//g; (my $temp_sender2=$row->[0])=~s/^.*?<|[EMAIL PROTECTED]//g;


if (!$lp1{$temp_sender1}{'department'})
{
$lp1{$temp_sender1}{'department'}=" ";
$lp1{$temp_sender1}{'branch'}=" ";
}



print $/,$/,'sender :',$temp_sender2,$/,'Department:',$lp1{$temp_sender1}{'department'},$/,'Branch:',$lp1{$temp_sender1}{'branch'},$/,$header if(!$seen{$temp_sender2}++);
print $row->[1],(' ' x (28-length($row->[1]))),
$row->[2],(' ' x (22-length($row->[2]))),$/;
}





---NOTICE--------------------------------------------------------------------------------------------------
This E-mail (including the attachment/(s) if any ) has been scanned for viruses and dangerous content. For more information mail to [EMAIL PROTECTED]
-----------------------------------------------------------------------------------------------------------
---DISCLAIMER----------------------------------------------------------------------------------------------
The contents of this E-mail (including the contents of the enclosure/(s) or attachment/(s) if any) are privileged and confidential material of Bennett, Coleman & Co. Ltd. (BCCL)and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee/(s). If this E-mail (including the enclosure/(s) or attachment/(s) if any ) has been received in error, please advise the sender immediately and delete it from your system. The views expressed in this E-mail message (including the enclosure/(s) or attachment/(s) if any) are those of the individual sender.
-----------------------------------------------------------------------------------------------------------



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to