open(CUSTORDS, ">\\\\bcedi\\d\$\\dsdata\\rp\\lby\\custords.dat")||die "Can't open file"; while ( my @row = $sth->fetchrow_array() ) { $lineStatus = $row[0]; $style = $row1; $colorCode = $row2; $lblCode = $row3; $totalQty = $row4; $startDate = $row5; $orderType = $row6; $orderNum = $row7; $orderStatus = $row8; $confType = $row9; $poNum = $row10; $customer = $row11; $sku = $style . $colorCode . ($space x (32 - length($style . $colorCode))); $company = $space x 3; $division = $space x 8; $corp = $space x 12; $sold = $space x 8; $dept = $space x 3; $shipTo = $space x 12; $totalQty = $totalQty . ($space x (8 - length($totalQty))); $poNum = $poNum . ($space x (13 - length($poNum))); $customer = $customer . ($space x (8 - length($customer))); $remarks = $space x 30; $orderStatus = $orderStatus . ($space x (4 - length($orderStatus))); $year = substr($startDate,0,4); $month = substr($startDate,5,2); $day = substr($startDate,8,2); $startDate = $year . $month . $day; $poNum = substr($poNum,0,13); print CUSTORDS "$sku$company$division$corp$sold$dept$shipTo$totalQty$space$poNum$customer$remarks$orderStatus$startDate\n";