in reply to Conflicts combining arrays?

The most serious problem with this code is the improper use of return in your subroutines. You aren't capturing the values your subroutines return. For example, if I want to get the return value of

sub double_each { return map {$_ * 2 } @_; }

I have to call it like this: @list_of_nums = double_each(@list_of_nums); (assuming, of course, I have numbers in @list_of_nums before I make the call. Currently, your calls to your search subs are simply throwing away the return values.

You're not using use strict here or running under -w (or with use warnings should you be using perl 5.6.0) as far as I can tell. If so, you would have been warned about using those arrays in "void context" (which is how Perl tells you you're throwing away the return values) But let's start with the biggest single thing: change those two lines before you create @matchlist and try the following:

my @descmatches = productsearchbydesc($pss); my @modelmatches = productsearchbymodel($pss);

That will get you part of the way.

Further advice: you've got two different subroutines that differ only in the array they search (otherwise the code is entirely interchangeable). Use that fact! Write ONE subroutine, and have it accept as arguments the search string AND a reference to the array that is to be searched:

sub searcharray { my ($terms, @array) = @_; ... my @matches = grep { $array[$_] =~ /$pattern/ } 0 .. $#array; @matches; } # call this with my @matches = searcharray($pss, @BKSIC_DESC);

Final note: it's much more efficient to pass around references to arrays and hashes than it is to pass around arrays and hashes. Read perlreftut for how to use references.

HTH.

Philosophy can be made out of anything. Or less -- Jerry A. Fodor