I went out fishing and brought home something. I got the data in a way to fit the previous script and now I can print the rows that match, but still can't skip the one who don't.
Thank you very much for pointing me in the correct direction. I'd be happy to figure it out myself if you could give me one more tip on this way.
What I can't figure out is how to sort before comparing and printing, so that I get the words that are present in both lists but are not aligned.
#!/usr/bin/env perl
use strict;
use warnings;
while (<DATA>) {
my ($f1, $f2,$perc1,$perc2) = (split)[0,-3,2,-1];
if ($f1 eq $f2){
print $f1,($perc1-$perc2),"\n";
}
else{
next;
}
}
print "\n";
__DATA__
antidemocratica 8 0.000274459 antidemocratica 58 0.000288782
antidemocratiche 1 3.43074e-05 antidemocratiche 33 0.000164307
antidemocratici 4 0.00013723 antidemocratici 31 0.000154349
antidemocraticità 1 3.43074e-05 antidemocraticità 1 4.979e-06
antidemocratico 14 0.000480303 antidemocratico 76 0.000378404
antidemocratico.questa 1 3.43074e-05 consensi 74 0.000368446
consensi 29 0.000994914 consenso 2543 0.0126616
consenso 109 0.00373951 consensocrazia 1 4.979e-06
consensuale 2 6.86148e-05 consensuale 60 0.00029874
consensuali 1 3.43074e-05 consensuali 15 7.4685e-05
consensus 2 6.86148e-05 consensualmente 9 4.4811e-05
corrotto 128 0.00439135 disonesta 7 3.4853e-05
disonesti 19 0.00065184 disonesti 29 0.000144391
OUTPUT:
antidemocratica-1.4323e-05
antidemocratiche-0.0001299996
antidemocratici-1.7119e-05
antidemocraticità2.93284e-05
antidemocratico0.000101899
consensuale-0.0002301252
consensuali-4.03776e-05
disonesti0.000507449
One of Crete's own prophets has said it: 'Cretans are always liars, evil brutes, lazy gluttons'.
He has surely told the truth.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.