On Jul 21, awarsd said:

>counter=0;
>foreach $line(@list1){
>    foreach $sec_line(@list2){
>      if($line eq $sec_line){
>            $counter++;
>            $new_list[$counter]=$line;
>        }
>    }
>}
>print @new_list;

There's no reason to use $counter.  Simply say

  push @new_list, $line;

But this is also a very slow way to compare two arrays.  If they're each
10 elements, you're doing 100 comparisons.  It's an O(N*M) operation
(where N and M are the sizes of the arrays).

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to