in reply to Re: Is there a more functional regex syntax?
in thread Is there a more functional regex syntax?
Or, as an improvement in the regex, /^(?=(\d+))(?:\d+-)?(\d+)$/, so that both $1 and $2 are always defined. So, as 1 line,
Or more simply, if you want to keep the variables separate,$totals[$_] += ($range =~ /^(?=(\d+))(?:\d+-)?(\d+)$/)[$_] for 0,1;
$total_min += ($range =~ /^(\d+)/)[0]; $total_max += ($range =~ /(\d+)$/)[0];
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
In Section
Seekers of Perl Wisdom