Hello Monks,

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.