Let me know if I should post more info.

I've been following your other thread as well. I tidied up the formatting of the code you posted so that when I looked at it I would be able to read it (it's amazing how accustomed we get to careful formatting, and anything less makes code difficult to read). I'm going to paste here your posted code after being tidied up a bit, and will follow it with a question.

# Part of the dependency_checks subroutine foreach my $pronoun ( @stopListNoun ) { if ( ( lc $pronoun eq lc $argument1 ) || ( lc $pronoun eq lc $argument2 ) ) { return; } } #Make sure searchkey is 1st arg: push ( @matches, $chapternumber, $sentencenumber, $sentence, $grammar_relation, $argument2, $argument1 ) if ( $argument2 =~ /$verbform/i ); # USED TO BE 'eq', but that # prevented protective from sh +owing push ( @matches, $chapternumber, $sentencenumber, $sentence, $grammar_relation, $argument1, $argument2 ) if ( $argument1 =~ /$verbform/i ); return \@matches; # Called by: $matches = &dependency_checks( $lines[$l], $verbform, $chapternumber, $sentencenumber, $sentence ); push @all_matches, $matches if ( $matches );

The question: Would you be able to look at that code and the description of the problem that you posted, and come up with any kind of meaningful answer?

There is so much missing that we cannot possibly know what this small snippet you posted is supposed to be doing. It's part of a bigger picture. If you look at a TV screen through a drinking straw and with the volume turned down, can you tell what's going on in the TV show?

I would like to help because I enjoy the puzzle of working through problems. But I have no idea what's going on in your code.

My recommendation is to post a snippet of code that is capable of compiling and running, but that shows the problem you're encountering. I don't mean 500 lines of code. I mean less than 30. If you are unable to reduce your problem to 30 lines of code, including a small sample of data, then the problem you think you're having isn't the problem. The real problem is disorganized and unmaintainable code which is leading you down a road to broken code.

One thing that I've found is that as I work on boiling a problem down to a minimal amount of code that I can post to get help, I usually solve my problem anyway. Just a couple days ago I was working on a piece of code that seemed like it worked great until I ran a specific test on it. Long story short, I spent way too long on it, and finally started preparing a small snippet to post here for advice. Two minutes into my effort to boil it down to a snippet small enough to post, I discovered the problem. Two minutes later I fixed the original code and executed the test successfully.

So I'll say it again. Please post an example of your input right before things break. Post an actual snippet of code that will compile and will take this input and break it. Tell us what output you should be getting, and how it differs from what's actually happening.

Help us help you.


Dave


In reply to Re: Return 2 arrays, sort the same, and concatenate them by davido
in thread Return 2 arrays, sort the same, and concatenate them by jonc

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.