see Markup in the Monastery before putting code
the problem is that the data in the final array(result array) is getting over written and not appended. please help me out.... :(
what you mean by final array here?
one more hint, every time inside the forloop you are using so may intermediate variables and it will get overwritten.
try printing those values inside the for loop and ensure that it prints properly, rather than seeing the values after the for loop.
according to your code the variables $err_loan_id1,@err_loan_id2,$reqd_1,@err_loan_id3,$reqd_2,@err_loan_id will have the values that belong to the last file in the array @cad_err_list if you print the values at the end of for loop
if you need only the final array then just have a hash declared at a global scope and maintain the intermediate variables like this.
inside forloop @err_loan_id = split(/>/,$reqd_2); $err_loan_id{$file} = [@err_loan_id];
now for every file the final array is saved, you can print at the end of for loop, try printing using Data::Dumper::Dumper you will recognize the output clearly now
similarly if you want to save all the intermediate values do like this inside your for loop.
$err_loan_id{$file} = [ $err_loan_id1,[ @err_loan_id2],$reqd_1,[@err_l +oan_id3],$reqd_2,[@err_loan_id]];
I think I have answered your question..

but you will end up in using more memory if you have so many files in @cad_err_list and because of that if the values in the intermediate variables are huge, then plainly using the methods shown by me is prone to problems, take care.


Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.

In reply to Re^3: appending multiple values in an array by targetsmart
in thread appending multiple values in an array by raghu_shekar

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.