Keep It Simple, Stupid | |
PerlMonks |
Re: compare 2 arrays of strings and form a tableby Roy Johnson (Monsignor) |
on Mar 10, 2009 at 18:09 UTC ( [id://749675]=note: print w/replies, xml ) | Need Help?? |
You're using numerical comparison (=) rather than string comparison (eq), and your loops aren't very Perlish. You don't describe your problem very clearly, but it looks like you want array2 to indicate values that follow corresponding values from array1: book follows read, apple follows eat, etc.
For the output, the first column should be things that don't appear in array2, and each subsequent column should be the values that follow the values in the previous column. If so, you want to reverse football and tennis in your example. I found it made the most sense to work with hashes so I could model the "follows" relationship.
Caution: Contents may have been coded under pressure.
In Section
Seekers of Perl Wisdom
|
|