## Perl - 41 Bytes ## <!-- language-all: lang-perl --> #!perl -pF, $\+=(/\d+ ?-/&&$'-$&>>/o|e/i)+1for@F}{ Counting the shebang as 3, input is taken from stdin. --- **Sample Usage** $ echo pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even | perl math-problems.pl 27 $ echo pg. 34: 1 | perl math-problems.pl 1 $ echo PG. 565: 2-5,PG.345:7 | perl math-problems.pl 5 $ echo pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80 | perl math-problems.pl 70