G'day smls,
In the code below, I've eliminated both temporary variables and reduced the foreach block of code to a single line:
$ perl -Mstrict -Mwarnings -e ' my @ranges = qw{15 28-31 3-4 40 17-19}; my ($total_min, $total_max); s{^(\d+)-?(\d*)$}{$total_min += $1; $total_max += $2 ? $2 : $1}e for @ +ranges; print "total is between $total_min and $total_max\n"; ' total is between 103 and 109
-- Ken
In reply to Re: Is there a more functional regex syntax?
by kcott
in thread Is there a more functional regex syntax?
by smls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |