Thanks everyone that helped me to get this done. I was finally able to do the shared word count on my own! Thanks again for all your time and help! And apl Trivial is a very relative term!!! I spent 20 hours to get the counting piece done. :)
$filename = "tryit.txt"; open(IN, $filename) || die; open(OUT, ">test1.csv") || die; open(OUT1, ">test2.csv") || die; my %freqs; my $story; # Current story name while (<IN>) { if (/^\<(.*)\>\s*$/) { $story = ucfirst $1; die "Duplicate story title: $story" if exists $freqs{$story}; next; } next unless defined $story; # wait until we have a story title s/[\.,:;\?"!\(\)\[\]\{\}(--)_]//g; for my $word (/\w+/g) { # Current story counts $word = ucfirst $word; $freqs{$word}{$story}++; $freqs{all}{$story}++; # Total counts $freqs{$word}{total}++; $freqs{all}{total}++; } } # Print title line print OUT "\t", (join "\t", sort keys %{$freqs{all}}), "\n"; # Print table for my $word (sort keys %freqs) { $freqs{$word}{$_} ||= 0 for keys %{$freqs{all}}; printf OUT "$word\t"; print OUT join "\t", join "\t", map $freqs{$word}{$_}, sort keys %{ +$freqs{$word}}; print OUT "\n"; } @info=sort keys %{$freqs{all}}; my @countop; for($i=0;$i<scalar(@info)-1;$i=$i+1) { $story1=$info[$i]; for($j=0;$j<scalar(@info)-1;$j=$j+1) { $story2=$info[$j]; for my $word (sort keys %freqs) { $freqs{$word}{$_} ||= 0 for keys %{$freqs{all}}; if($freqs{$word}{$story1} > 0){ if($freqs{$word}{$story2} > 0){ $countop[$i][$j]++;}} } } } my $m; my $n; for($m=0;$m<scalar(@info)-1;$m=$m+1) { for($n=0;$n<scalar(@info)-1;$n=$n+1) { printf OUT1 "$info[$m],$info[$n],$countop[$m][$n] \n"; } } close IN; close OUT; close OUT1;

In reply to Re^3: Add colums and rows by lechateau
in thread Add colums and rows by lechateau

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.