remluvr has asked for the wisdom of the Perl Monks concerning the following question:
Hi everyone. Is it possible to read two file in parallel and grab values from them? I mean, let's say I have two input file. The first is like this:
and the second like this:alligator-n attri aggressive-j 0.0521953848067504 alligator-n attri aquatic-j 0.0428300684553727 alligator-n attri big-j 0.125268137962678 alligator-n attri carnivorous-j 0.0218253043999405 lizard-n hyper creature-n 0.618765795370872 lizard-n hyper reptile-n 0.466342631493931 lizard-n hyper vertebrate-n 0.249202543226053 lizard-n mero blood-n 0.397326263768692 dishwasher-n random-v prevent-v 0.00856940857204332 dishwasher-n random-v qualify-v 0.00675098458337709 dishwasher-n random-v top-v 0.0114499058531553 dishwasher-n random-v visit-v 0.0134718844088632 freezer-n attri big-j 0.0865285153310031 freezer-n attri clean-j 0.078801694198009
alligator-n attri aggressive-j 0.345621780 alligator-n attri aquatic-j 0.46634263149393 alligator-n attri big-j 0.125268137962678 alligator-n attri carnivorous-j 0.0218253043999405 lizard-n hyper creature-n 0.618765795370872 lizard-n hyper reptile-n 0.466342631493931 lizard-n hyper vertebrate-n 0.0428300684553727 lizard-n mero blood-n dishwasher-n random-v prevent-v 0.00856940857204332 dishwasher-n random-v qualify-v 0.00675098458337709 dishwasher-n random-v top-v 0.125268137962678 dishwasher-n random-v visit-v 0.0134718844088632 freezer-n attri big-j0.078801694198009 freezer-n attri clean-j 0.397326263768692
That is they are exactly the same, except for the last value. How can I read them in order to confront the last value of each line of the first file with the value of the exactly same line in the second file?For each line I have to apply the following formula: value_from_the first*(1-value_from_the_second).My output should look like the input, except for the last value, which should be derived as the previous formula suggested. Thanks a lot. Giulia
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read and analyze two file in parallel
by roboticus (Chancellor) on Mar 14, 2012 at 21:51 UTC | |
by CountZero (Bishop) on Mar 14, 2012 at 22:45 UTC | |
by remluvr (Sexton) on Mar 14, 2012 at 22:06 UTC | |
by aaron_baugher (Curate) on Mar 14, 2012 at 22:21 UTC | |
by Anonymous Monk on Mar 15, 2012 at 08:39 UTC | |
by Anonymous Monk on Nov 21, 2012 at 10:58 UTC |