Hi, could any one help to debug this code plz thanks in advance

#!/usr/local/bin/perl
# load_bulkups.pl - create bulkup orders from a csv file
# the input file should be in the comma seperated, in the
# following format:
# site,vendor,sku(Stock Keeping Unit),forecast,qoh(Quantity on Hand),qoo(Quantiy on Order),buying_multiple,outl,demand,order
# if an order quantity is 0, it is assumed that that sku
# will not be ordered. each file will only contain one vendor.


use DBI;
use Net::SMTP;


$ENV{'ORACLE_HOME'} = '/app/oracle/product/9.2';


my $usr = 'aaaaa_bbbb';
my $pwd = 'cccccc';
my $tns = 'DPR';


my $dir = '/tmp/bulkups';       # working directory


my $dbh = DBI->connect("dbi:Oracle:$tns", $usr, $pwd)
or die "couldn't connect: " . $DBI::errstr;


chdir($dir);


foreach my $file (<*.csv>) {
open(IN, $file);
if ($file =~ /[A-Z0-9]*_([A-Z0-9]*)_(\d.*\d)_(\d.*\d)_([a-z]*)\.csv/) {
($ca, $begin_date, $end_date, $email) = ($1, $2, $3, $4);
}
$dbh->do("delete from cx_bulkup");
while(<IN>) {
chomp $_;
my ($site, $vendor, $sku, $desc, $forecast,
$qoh, $qoo, $buying_multiple,
$outl, $demand, $cost, $order, $buyer, $cancel_date) = split(/,/, $_);
if($order eq '') { $order = 0; }
if($ca eq 'DEFAULT') { $ca = '*DEFAULT'; }
$dbh->do("insert into cx_bulkup
(source_enterprise_code,
source_be_code_type,
source_be_code,
destination_enterprise_code,
destination_be_code_type,
destination_be_code,
ca_addendum_code,
item_code_type,
item_code,
order_approval_date,
expected_delivery_date,
order_quantity,
buyer,
cancel_date,
processed
) values (
'VENDORS',
'TOMAX',
'$vendor',
'STORES',
'TOMAX',
'$site',
'$ca',
'TOMAX',
'$sku',
'$begin_date',
'$end_date',
$order,
'$buyer',
'$cancel_date',
0
)");
}
$dbh->do("begin cx_bulk_export; end;");
$d_o = $dbh->selectcol_arrayref('select message from cx_tmp_bulkup_msg');
$smtp = Net::SMTP->new('176.0.0.1');
$smtp->mail('dpr-prod@repl1.holiday.net');
$smtp->to($email . "\@holiday.net");
$smtp->data();
$smtp->datasend("Subject: Bulkup load results\n");
$smtp->datasend("\n");
foreach my $data (@$d_o) { $smtp->datasend($data ."\n"); }
$smtp->dataend();
$smtp->quit();


}

Recommended Answers

All 4 Replies

Hi, could any one help to debug this code plz thanks in advance
#!/usr/local/bin/perl
# load_bulkups.pl - create bulkup orders from a csv file
# the input file should be in the comma seperated, in the
# following format:
# site,vendor,sku(Stock Keeping Unit),forecast,qoh(Quantity on Hand),qoo(Quantiy on Order),buying_multiple,outl,demand,order
# if an order quantity is 0, it is assumed that that sku
# will not be ordered. each file will only contain one vendor.

use DBI;
use Net::SMTP;
<snip>
lots of code deleted
</snip>
}

How can we help you debug your script if we don't know what, if any errors you are getting? What are you expecting it to do? What in fact does it do? Asking someone to 'debug my script' is like asking someone to do your homework for you. What have YOU done to debug it?

it's probably those smilies in the code..... I don't think perl handles smilies too well...... ;)

Yes, what the heck are those any way? Why are they inserted at such a place?

the poster did not use the code tags so smilies get automatically inserted into the post.

use NET::SMTP;

use NET::SMTP;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.