I am sending the email to the [EMAIL PROTECTED] and I am sending to you also as this is urgent.
That's why myself and many others read the beginner's list, to fix you up as fast as possible.
Using your previous help I can able to solve my problems.
Glad I could help.
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'm with you this far.
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
You lost me right here. Sorry, I'm not sure what you're trying to calculate from what. Can you give an example? In the above text, what would the total cost equal and what math did you do to get that. I must be dumb today. :)
how to do this taks in the following code.
#!/usr/bin/perl -w
$!=1;
This is not needed. Omit it.
use strict;
use warnings;
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;
I've already shown you a much better way to handle the above file read and processing in a previous message.
# 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;
I don't understand what is going on above, but I don't think it's good. Why are we setting to variables to the exact same thing?
if (!$lp1{$temp_sender1}{'department'}) {
Are you trying to test if the entry doesn't exist here? That would probably be better as:
if (not exists $lp1{$temp_sender1}) {
$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]))),$/;
}
I like "\n" better than $/, though that's just a stylistic preference.
Send, back to the list, some details about the calculation you're trying to find and I'll try to help you get there.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]