brpower has asked for the wisdom of the Perl Monks concerning the following question:
I am looking to right justify ONLY the totalQty field in below script. How do I accomplish this?
open(CUSTORDS, ">\\\\bcedi\\d\$\\dsdata\\rp\\lby\\custords.dat")||die +"Can't open file"; while ( my @row = $sth->fetchrow_array() ) { $lineStatus = $row[0]; $style = $row[1]; $colorCode = $row[2]; $lblCode = $row[3]; $totalQty = $row[4]; $startDate = $row[5]; $orderType = $row[6]; $orderNum = $row[7]; $orderStatus = $row[8]; $confType = $row[9]; $poNum = $row[10]; $customer = $row[11]; $sku = $style . $colorCode . ($space x (32 - length($style . $colorCod +e))); $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$s +pace$poNum$customer$remarks$orderStatus$startDate\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: right justify
by rjt (Curate) on Jul 17, 2013 at 14:29 UTC | |
by brpower (Initiate) on Jul 17, 2013 at 15:21 UTC | |
|
Re: right justify
by CountZero (Bishop) on Jul 17, 2013 at 14:33 UTC | |
|
Re: right justify
by pachydermic (Beadle) on Jul 17, 2013 at 14:18 UTC | |
by marto (Cardinal) on Jul 17, 2013 at 15:21 UTC |