in reply to Is there a more functional regex syntax?
I think this is the prettiest I could make it...
#!/usr/bin/perl use strict; use warnings; my @ranges = ('15', '28-31', '3-4', '40', '17-19'); my @totals = (0, 0); foreach my $range (@ranges) { $totals[$_] += (split /-/, $range)[$_] for 0, -1; } print "total is between $totals[0] and $totals[-1]\n";
... it's arguably less readable though.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is there a more functional regex syntax?
by smls (Friar) on Sep 18, 2012 at 16:42 UTC | |
by tobyink (Canon) on Sep 18, 2012 at 16:57 UTC |