I have a tabbed file; the first field is the primary key of the table ($descid), the second is different ID ($conid), and the third is a string with (possibly) non-ascii characters.

I am trying to capture my matches of non-ascii characters from the string field into a hash to count each of those matches. The list of all character matches from a single run through the inner loop (a single row of the table) is to be the value of another hash keyed on $descid. Finally, $conid is to be the key to a hash whose value is the list of $descid in the table as a whole.

In other words, I want an inner hash counting character matches, a list of hashes, a hash of lists keyed on $descid, and a hash of hashes keyed on $conid

I can capture the characters in the code shown. How do I capture the list of characters matched from a single row of the table to put them into an annonymous array to become the value of the outer hash? I have looked through the camel, the lol tutorial, and other places, but I don't see the answer. I tried making the inner loop:

while(@rowmatches = /[^\x{1}-\x{7f}]/go){ ...
thinking that capturing the matches in list context would do it, but it didn't.
my %chars; # my $descid; # my $conid; while (<>) { while (/[^\x{1}-\x{7f}]/go){ ++$chars{$&}; } } foreach my $char (keys %chars){ print "$char found $chars{$char} times\n"; } print "found ". keys(%chars) . " distinct non-ascii chars\n";

In reply to capturing the numerous hits from a global match into nested data by jjohhn

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.