in reply to is there a more simple way to have the intersection of two lists ?

Use CPAN instead.
use Set::Scalar; my @filenames = ( 'name1.txt', 'name2.txt' ); my @sets = map { read_file_to_set( $_ ) } @filenames; my $intersection = $sets[0]->intersection( $sets[1] ); print "$intersection\n"; sub read_file_to_set { my ($filename) = @_; open my $fh, '<', $filename or die "Cannot open '$filename' for reading: $!\n"; chomp( my @lines = <$fh> ); close $fh; return Set::Scalar->new( @lines ); }

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re: is there a more simple way to have the intersection of two lists ?
  • Download Code