Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by choroba (Canon)
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; # ...
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: ignore duplicates and show unique values between 2 text files
Download Code
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2015-07-31 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (277 votes), past polls