My idea of solving this is putting the intervals into an array and then selecting the "right" bucket for the length. I assume that you can somehow get at the playlength of a file in seconds. (untested code follows):

my @playlengths = ( 0, 1*60, 2*60, 3*60, 4*60, 5*60, # this is just to show 10*60, # that we can have gaps in the array 60*60, # and anything longer than one hour # goes into this bucket ... 2147483648, # I use this as an easy end-of-array marker ); # First we retrieve the playlength in seconds # from the current file for later reference my $playlength = &getPlaylength( $file{$pos}); # $slot will hold the position of our file # so @playlengths[$slot] <= $playlength < $playlengths[$slot+1] # always holds my $slot = 0; while ($playlength < @playlengths[$slot]) { $slot++; }; if ($slot == $#playlengths) { print "The file playlength is longer than $playlengths[$slot] second +s.\n"; } elsif ($slot == 0) { print "The file playlength is below ",$playlengths[1]," seconds.\n"; } else { print "The file playlength is between $playlengths[$slot] and $playle +ngths[$slot+1] seconds." };

In reply to RE: Numeric summarisation from data in a hash? by Corion
in thread Numeric summarisation from data in a hash? by dmtelf

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.