One problem:

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $x = 'CA006139520,\"WINDSOR RIVERSIDE, ON CA\",2018-01-02,10'; ;; my @windsordigits; @windsordigits = $x =~ /WINDSOR\sRIVERSIDE.*(\d\d?)/; dd \@windsordigits; " [0]
When the last two digits of the line are '10', why is only '0' captured? The  .* "consumes" as much as possible of non-newline stuff (including digits), the  \d is required for a match, but the  \d? is not, so only one digit is captured. Try something like:
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $x = 'CA006139520,\"WINDSOR RIVERSIDE, ON CA\",2018-01-02,10'; ;; my @windsordigits; @windsordigits = $x =~ /WINDSOR\sRIVERSIDE.*\b(\d+)\z/; dd \@windsordigits; " [10]
to get all digits at the end of the line. (Update: If the line may end in an un-chomp-ed newline, use  \Z (big-Z) instead of  \z (little-z) as the end-of-line anchor.)

Another problem:

@windsordigits = ...;
You're assigning a single item to the array on each pass through the while-loop; the array will never have more than a single item in it no matter how many lines you read. Try something like (untested):
push @windsordigits, $x =~ /WINDSOR\sRIVERSIDE.*\b(\d+)\z/;
(Update: E.g.:
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my @windsordigits; ;; for my $x ( 'CA006139520,\"WINDSOR RIVERSIDE, ON CA\",2018-01-02,10', qq{CA006139520,\"WINDSOR RIVERSIDE, ON CA\",2018-01-02,987\n}, qq{CA006139520,\"WINDSOR RIVERSIDE, ON CA\",2018-01-02,6\n}, ) { push @windsordigits, $x =~ /WINDSOR\sRIVERSIDE.*\b(\d+)\Z/; } dd \@windsordigits; " [10, 987, 6]
Note use of  \Z anchor.)

See the flip-flop operator  .. in perlop for help with the line-range problem. (Update: See use of range operator  .. "As a scalar operator ..." in perlop.)


Give a man a fish:  <%-{-{-{-<


In reply to Re: Illegal division by zero by AnomalousMonk
in thread Illegal division by zero by drose2211

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.