Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by LanX (Canon)
on Apr 29, 2013 at 15:58 UTC ( #1031248=note: print w/ replies, xml ) Need Help??


in reply to Re^2: ignore duplicates and show unique values between 2 text files
in thread ignore duplicates and show unique values between 2 text files

> is this possible?

yes, but we won't post whole code!

Apply

my ($number,$article) = split /\s+/, $line, 2

for each input line and decide which part should be unique.

learn to do it yourself with split.

Cheers Rolf

( addicted to the Perl Programming Language)

UPDATE

added missing third parameter for split


Comment on Re^3: ignore duplicates and show unique values between 2 text files
Download Code
Re^4: ignore duplicates and show unique values between 2 text files
by kennethk (Monsignor) on Apr 29, 2013 at 16:07 UTC
    I think your posted code will not follow the posted spec. The posted lines contain additional whitespace, so my ($number,$article) = split /\s+/, $line will yield
    $number = 261293 $article = 'snow
    as opposed to split /\t/, $line, which would yield
    $number = 261293 $article = 'snow > equipment > helmets'
    Update: Parent code updated

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Well sorry I noticed my problem after I saw your code and updated it in the meantime. =)

      Anyway considering the bad data the OP showed till now, it's better not expecting '\t' as delimiter...

      ... at least as long as there is no third column coming into play. =)

      Cheers Rolf

      ( addicted to the Perl Programming Language)

        Not the cleanest problem statements, to be sure. I still want to know why the OP cares that the records contain multiple 'columns'.

        I tried communicating the code issue via private msg when I spotted it, but you appear to be ignoring me.


        #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031248]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-11-23 21:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (134 votes), past polls