Philipp Gruemmer wrote: > A small correction (thanks to Carlos Diaz) > >> Isn't shis code supposed to read the first line of the @input array then >> read the first line of the @blacklist array, see if the $line contains a >> $cond and then ptrint "true". After that it should carry on with the >> second line from both arrays.... > > I want every line of the @input array to be checked with all the lines > from the @blacklist array. > > Get first line from @input > Cycle through @blacklist -> If sth. matches, do something > Get second line from @input > Cycle through @blacklist -> If sth. matches, do something > [...etc...] > > > Greeting, philipp
You could try playing with Quantum::Superpositions I've got a small test case I love showing people who know C/C++, to show how two arrays can be compared for missing items without using a nested loop. observe: #!/usr/bin/perl use warnings; use strict; my @Array1 = qw(cat dog mouse rat); my @Array2 = qw(mouse bird rat snake); print "\nArray 1 contains: @Array1\n", "Array 2 contains: @Array2\n\n"; print<<"END"; hmm. how to find out which elements from one array are missing from the other without doing nested loops? aha! Quantum Mechanics! END use Quantum::Superpositions; my @notinarray1 = map { $_ } eigenstates( any(@Array2) ne all(@Array1) ); my @notinarray2 = map { $_ } eigenstates( any(@Array1) ne all(@Array2) ); print "@notinarray1: not found in Array 1\n", "@notinarray2: not found in Array 2\n"; __END__ Quantum::Superpositions requires Class::Multimethods. I haven't played much with this regarding regular expression matching rather than string matching. Feel free to contact the current maintainer if you run into problems. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]