With thanks to tye and jdporter, the length method has been rewritten as follows:
sub length { my ($self, $uri); my $length = 1; if (ref($_[0])) { $self = shift; $uri = $self->{uri}; } else { $uri = shift; } while ($uri =~ m/((?:\{[^\}]+\})|(?:\[[^\]]+\]))/ig) { if ($1 =~ m/\{([^\}]+)\}/i) { my $temp = $1; $length *= ($temp =~ tr/,/,/); } elsif ($1 =~ m/\[([^\]]+)\]/i) { my ($start, $stop) = sort split('-',$1); $stop = $start+10 unless ($stop); if ($start =~ /\d+/) { #There is one or more digit, so we'll remove anything + else that might be there $start =~ s/\D+//g; $stop =~ s/\D+//g; } $length *= $stop - $start + 1; } } return $length; }
However, this still isn't entirely perfect. These are some examples from my current log that generate inconsistent results:
scalar($uriobj->as_list) $uriobj->length $uri 1 0 foo{011-047}bar 0 -398 foo[800-1199]bar 0 -348 foo[850-1199]bar 0 -298 foo[900-1199]bar 0 50 foo[001-50]bar 0 -97 foo[2-100]bar 0 -97 foo[2-100]bar 0 -7 foo[2-10]bar 1 0 foo{001-188}bar 0 -140 foo[01-20]bar 0 -3 foo[1-05]bar 0 -46 foo[53-100]bar 975 -23 foo[001+-+025]bar 9 6 foo{one,two,three}/[01-03]bar 27 6 foo{one[01-03],two,three}/[01-03]bar 0 -120 foo[2-13]/[01-12]bar 0 -120 foo[2-13]/[1-12]bar 0 -90 foo[2-13]/[1-9]bar 0 101 foo[0000-100]bar 0 41 foo[0000-40]bar 0 -10 foo[8-19]bar 0 -399 foo[600-1000]bar 1 0 foo{011-047}bar

In reply to Re: Possibly long lists and memory leaks by carthag
in thread Possibly long lists and memory leaks by carthag

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.