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

Re: Merging two list with simple operation

by BrowserUk (Patriarch)
on Jul 31, 2010 at 18:11 UTC ( [id://852263]=note: print w/replies, xml ) Need Help??


in reply to Merging two list with simple operation

Wrapped. Needs mods for *nix shells:

sort file1>file1.s & sort file2>file2.s & join file1.s file2.s | perl -anle"print$F[0],' ',$F[1]*$F[2]" | sort -n -k 2 > files.merged & del file1.s file2.s c:\test>type files.merged hello 1 FILE 2 today 6 yes 8 well 12

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Merging two list with simple operation
by fanticla (Scribe) on Jul 31, 2010 at 18:31 UTC

    @BrowserUk; Thanks, it works. I'm though trying to come up with a pure perl solution, without any sort command, as sorting my cause problems. The two lits may also be slightly different.

      without any sort command, as sorting my cause problems.

      Why would do you think sorting would cause cause problems?

      The two lits may also be slightly different.

      Different how? If it is anything other than casing, it will screw up most solutions.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        I see sorting problems with characters other than Latin (of course this problems can be also solved)

        Different lists means that the items can be different in the two lists, such as TermX is in list 1 but not in list 2. The problem can easily be solved: considering only terms that are in both lists, or giving a x-value to terms that are missing in one of the two lists. Remember, the goal of the script is reranking the terms in the 2 lists.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-23 16:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found