We are passing an array reference of results sets from the main program to this function which prints the contents of the result sets to the flat file. In this case,not able to print the contents. here is the code snippet of the function
The array reference is in argument 6
sub pkoutFile { my(@args)= @_; my($val, $i,$j,$k,$k1,$ln,@ff,@ss,$delim1, $delim2, @paramVals ); # 0 1 2 3 4 5 + 6 my($outFH, $delims, $branchID, $sourceSystem, $valDateY4MD, $rate +Type, $rowsHdl ) = @args[0..6]; $colNamesHdl = $args[7] if ($#args >= 7); $delims =~ s/(^[\n\r\s\t]+)|([\n\r\s\t]+$)//g; $branchID =~ s/(^[\n\r\s\t]+)|([\n\r\s\t]+$)//g; $valDateY4MD =~ s/(^[\n\r\s\t]+)|([\n\r\s\t]+$)//g; $sourceSystem =~ s/(^[\n\r\s\t]+)|([\n\r\s\t]+$)//g; $rateType =~ s/(^[\n\r\s\t]+)|([\n\r\s\t]+$)//g; $delim1 = substr($delims,0,1); $delim2 = substr($delims,1,2); printf($outFH "H\^%s\^%s\^%s\^%08d^\n", $delims, $branchID, $sourceS +ystem, $valDateY4MD); # determine the field names if ($colNamesHdl) { @ff=(); for ($i=0; $i <= $#$colNamesHdl; $i++) { push(@ff, $$colNamesHdl[$i]); } } else { $k = $$rowsHdl[0]; @ff = keys(%$k); } $j = $#$rowsHdl; for ($i=0; $i <= $j; $i++) { @paramVals = (); foreach $k (@ff) { $k1= $k; $k1 =~ s/(^[\n\r\s\t]+)|([\n\r\s\t]+$)//g; $val = $$rowsHdl[$i]->{$k}; # add logic here to make sure that the delims are NOT in the tex +t push(@paramVals, $k . $delim2 . $val); } print($outFH ('C^D^' . $rateType . '^' . join($delim1, @paramVals +) . "^\n")); } print($outFH "T^${branchID}^${sourceSystem}^\n"); }
Need your help to print the contents of the array reference to the file
In reply to Unable to print the contents of an array reference passed from the main pgm to the flat file by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |