pen (FILE1,"textfile1.txt") or die $!; while(){push(@value1,(split(/;|\s+/,$_))[-1]);} close(FILE1); open (FILE2,"textfile2.txt") or die $!; while(){push(@value2,(split(/;|\s+/,$_))[-1]);} close(FILE2); my %in_list1; foreach my $element(@value2){$in_list1{$element}=();} foreach my $item(@value1){ if (exists $in_list1{$item}){push(@notval,$item);}else{push(@notval,"0");} } $ll=join (';',@value1); $m='$1='."[$ll]
"; $kk=join (';',@notval); $n='$2='."[$kk]"; print $m; print $n;