As the variable $tally is defined beforehand and preceded by the keyword "my", I don't understand what is wrong. How could I fix this?

You have declared $tally which is a scalar but the errors are telling you about @tally which is an array. Since your loops refer to the array and not the scalar, that is what you need to declare instead. See the basic datatypes, three for more about the basic data types in Perl and how the sigils relate to them.

How could I get rid of "(?^:" and ")"?

You could process the string which you actually output to achieve this but in this particular case you can avoid that by using quotes to delimit each regex in the first place instead of using the qr// operator. You can use single quotes 'foo' or q/foo/ for non-interpolated strings. ie:

my @regexes = (q/§\s*[0-9]/, q/Art\.\s*[0-9IVX]/, q/Artikel\s*[0- +9IVX]/, q/Artikels\s*[0-9IVX]/, q/Artikeln\s*[0-9IVX]/);

Bear in mind that these are now just simple strings so you need to take care to explicitly use them in a regex content. But as that is what the rest of your code does anyway, there is no further change required here.

Would it be possible to save this output to a file?

Of course. See eg. Re: How do I write to a file?

Do have a browse through the Tutorials section here and the Getting Started with Perl section in particular. These should help you achieve some of these simple tasks while you become more familiar with the language.


🦛


In reply to Re^5: Entity statistics by hippo
in thread Entity statistics by LexPl

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.