I realize this can be done very nicely with hashes, but everytime I hear, "in this but not in this," I think set operations, and then I think Set::Scalar.
#! perl use strict ; use warnings ; use Set::Scalar ; my $signal = Set::Scalar->new ; open INFILE, "<signal.txt" or die "can't open file" ; my @signal_list = <INFILE> ; close INFILE ; chomp @signal_list ; $signal->insert( @signal_list ) ; my $orderednames = Set::Scalar->new ; open DATA, "<orderednames.txt" or die "can't open sentences" ; while ( <DATA> ) { my @tokens = split( /\t+/, $_ ) ; foreach my $token ( @tokens ) { $orderednames->insert( $token ) ; } } close DATA; print "In signal:\n" ; print $signal, "\n\n" ; print "In orderednames:\n" ; print $orderednames, "\n\n" ; print "In signal, but not in orderednames:\n" ; print $signal - $orderednames, "\n\n" ; exit;
In reply to Re: searching and printing what is wanted
by DamnDirtyApe
in thread searching and printing what is wanted
by snowy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |