sub btween (\%$$) { my ($hash, $from, $until) = @_; my @found = grep { $hash->{$_}->{VLENGTH} >= $from && $hash->{$_}->{VLENGTH} < $until } keys(%{$hash})); my $titles = join(', ', map { $hash->{$_}->{TITLE} } @found); return ($#found, $titles); } my @result = btween(%hash, 0, 60); print "There are $result[0] clips between 0-1 minutes, and their names are: $result[1]\n";