brian_d_foy gave you pretty much the answer you need, but he didn't mention some of the foibles in your code that make it clear Perl is not your first language. :)
Perl is pretty good at handling lists of things, to the extent that there is a special version of the for loop to itterate over lists. Your nested loops could be rewritten as:
for my $line (@lines){ for my $line2 (@lines2){ next if $line !~ /$line2/; print $line; print "\nyes $line2 exists\n\n"; } }
One side effect of that is to remove $a and $b - which actually are special variables in Perl because they are used as the two arguments passed into a sort block.
In reply to Re: Improving a script to search for keywords in a file
by GrandFather
in thread Improving a script to search for keywords in a file
by stort83
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |