If you are certain the input to your subroutine is correct but your subroutine is returning an incorrect result then your subroutine is not written correctly. I can't help you fix the problem because you haven't shown me what input the subroutine receives or what result it must return. My uncertainty is only increased by the difference between the code in your original post and that in your recent post.

You might find brian's Guide to Solving Any Perl Problem helpful. It has some good advice about how to find and correct the causes of errors.

I can only help you further if you post what your input is and what your output must be. The best way to show this would be to present perl code which produces the required data structures, similar to what Data::Dumper produces. For the subroutine input, it would be best if your put the following at the beginning of your subroutine, before anything else in your subroutine, and posted the output.

{ use Data::Dumper; my $log = "/tmp/log.txt"; # change to some convenient path open(my $fh, '>', $log) or die "$log: $!"; print $fh, Dumper(\@_); close($fh); }

If you post what gets written to the log file, then I will at least know what the input to your subroutine is.

To determine what the output should be, you can write a subroutine which ignores its input and returns a constant data structure which produces useful/correct output. Then you can use Data::Dumper to dump this data structure and post it.

If you do this, I might be able to help you further. Otherwise, I wish you good luck with Brian's advice.


In reply to Re^3: WHAT IS WRONG TO PASS PARAMETER TO THE ARRAY? by ig
in thread WHAT IS WRONG TO PASS PARAMETER TO THE ARRAY? by courierb

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.