in reply to Return 2 arrays, sort the same, and concatenate them
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Return 2 arrays, sort the same, and concatenate them
by Anonymous Monk on Jul 01, 2011 at 06:40 UTC | |
by jonc (Beadle) on Jul 01, 2011 at 11:55 UTC | |
|
Re^2: Return 2 arrays, sort the same, and concatenate them
by jonc (Beadle) on Jul 01, 2011 at 13:08 UTC |