in reply to number sequence

So; you write two subroutines, one to handle the range case and the other to handle the simple number. Call them ranger() and simple().

Then you a write a routine to manage the worker routines (manager()). The manager function tests its argument for the presence of a '-'. If the hyphen is present, pass the argument to ranger($arg); otherwise call simple($arg) and return the result in either case.

Finally you write your controller control(), which is responsible for decomposing your input string into smaller bits:

  1. If there is a comma in the input then
    • split the string in two at the comma (stra, strb)
    • process the first string -- $ra = control($stra)
    • process the second one -- $rb = control($strb)
  2. If there are no commas in the input, pass the string to the manager routine $ret = manager($parm_string).
  3. Remember to do the right thing with the return strings.

Welcome to the world of iterative parsing; recursive descent is your friend.

Update -- added tag to close the list.

----
I Go Back to Sleep, Now.

OGB