Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: ignore duplicates and show unique values between 2 text files

by choroba (Chancellor)
on Apr 29, 2013 at 15:04 UTC ( #1031228=note: print w/replies, xml ) Need Help??


in reply to ignore duplicates and show unique values between 2 text files

The reason of your problem is the newline character. It is considered a part of the line you read in, but it is not present on the last line in each file. Therefore, '121' plus newline is not the same as '121' without a newline.

Use chomp to get rid of newlines:

while (my $line = <FILE>) { chomp $line; # ...
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: ignore duplicates and show unique values between 2 text files
by perlnoobster (Sexton) on Apr 29, 2013 at 15:09 UTC
    Hi Choroba, I have updated the script however my output still does not show the desired results, it show:
    'def' 'xyx' 'def' 'abc'
      You should use chomp for the second file handle, too.
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031228]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2016-12-03 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (52 votes). Check out past polls.