#! perl -w my $blat = 'C:\blat\blat.exe '; @recips = ('scg@yyyy.com'); $whereto="F:/Apps/"; $date = time(); (undef, undef, undef, $day, $mon, $year) = localtime $date; $year = $year + 1900; $mon++; $data = "OATS"; $current=$year.sprintf("%02d",$mon).sprintf("%02d", $day); $data = $whereto.$data; #print $data."\n"; ($currentfile) = reverse glob($data."\\*.lis"); $translate = $data."\\OATS.".$current.".csv"; %disp_table = ('OE'=>\&oentry, 'NW'=>\&nwentry, 'CL'=>\&clentry, 'EX'=>\&exentry, 'OR'=>\&orentry, 'CL'=>\&clentry, 'RT'=>\&rtentry, 'CR'=>\&crentry); open IN, "<".$currentfile; open OUT, "+>$translate"; print OUT 'Record Type, OE Type, Receive Firm ID, Received Date, Order ID, Routing Firm MP ID, Symbol, Buy/Sell, Shares/Quantity, Limit Price, Time in Force, Account Type, Method Code, Special Handling, Branch Seq #, Event Timestamp, Cancel Type, Cancel Flag, Received OE ID, Order Firm, Action Code, Ex. Time, Routing Firm, Replaced Order ID, Replaced Order time'."\n"; while (){ &initvar; @row = split /,/; if ($row[0] eq '#OE#'){ (($disp_table{$row[1]}->(@row))||&deft); &prtout; } } close IN; close OUT; open TXT, ">$data\\msg.txt"; print TXT "OATS feed file report for ".$date; close TXT; for (@recips){ system ($blat.$data."\\msg.txt".' -to "'.$_.'" -attach "'.$translate.'"'); } sub exentry { ($rectype, $oetype, $recdate, $orderid, $timestamp, $branchseq, $quantity, $symbol) = @_[0, 1, 7, 8, 9, 10, 11, 14]; } sub rtentry{ ($rectype, $oetype, $action, $ROEID, $orfirm, $recdate, $orderid) = @_[0, 1, 2, 3, 6, 7,8]; ($rtfirm, $symbol, $xtime, $quantity, $method)= @_[9, 11, 12, 13, 14]; } sub clentry{ ($rectype, $oetype, $action, $ROEID, $orfirm, $recdate, $orderid, $symbol, $timestamp) = @_[0, 1, 2, 3, 6, 7,8, 9, 10]; ($ccltype, $cclflag) = @_[11, 14]; } sub crentry{ ($rectype, $oetype, $action, $ROEID, $orfirm, $recdate, $orderid) = @_[0, 1, 2, 3, 6, 7,8]; ($ordertimer, $orderidr, $orderid, $rtfirm, $xtime, $method, $symbol, $side, $quantity, $limit, $tif, $spechand, $accttype) = @_[7, 8, 10, 11, 13, 14, 15, 16, 17, 18, 21, 25, 33]; } sub nwentry{ ($rectype, $oetype, $recdate, $orderid, $mpid, $timestamp, $method, $symbol, $side, $quantity, $limit, $tif, $accttype) = @_[0, 1, 7, 8, 9, 10, 12, 13, 14, 15, 16, 19, 31]; } sub oentry{ ($rectype, $oetype, $action, $recdate, $orderid, $mpid, $timestamp, $symbol, $side, $limit, $tif, $spechand, $accttype, $branchseq, $quantity) = @_[0, 1, 2, 7, 8, 9, 10,13, 14, 15, 18, 22, 30, 34, 35]; } sub orentry{ ($rectype, $oetype, $recdate, $orderid, $mpid, $timestamp, $symbol, $side, $limit, $tif, $accttype, $quantity) = @_[0, 1, 7, 8, 9, 10,13, 14, 15, 19, 31, 35]; } sub prtout{ $recdate = &formDate($recdate); $timestamp = &formDate($timestamp); $xtime = &formDate($xtime); $ordertimer = &formDate($orderTimer); print OUT join ', ', ($rectype, $oetype, $recid, $recdate, $orderid, $mpid, $symbol, $side, $quantity, $limit, $tif, $accttype, $method, $spechand, $branchseq, $timestamp, $ccltype, $cclflag, $ROEID, $orfirm, $action, $xtime, $rtfirm, $orderidr, $ordertimer); print OUT "\n"; } sub initvar{ $rectype=$oetype= $recid= $recdate= $orderid= $mpid= $symbol= $side= $quantity= $limit= $tif=$accttype= $method= $spechand= $timestamp = $branchseq= $action= $ROEID= $orfirm= $ccltype= $cclflag=$xtime=$rtfirm= '';} sub deft{ return 1; } sub formDate{ my $enter = shift; $enter =~ s!(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})!$2/$3/$1:$4:$5:$6!; return $enter; }