HPGL to arduino?

I am trying to make the arduino receive and process HPGL commands from the serial port. How can I break a single command into multiple parts.
For example if the arduino gets: PU50,50;

i want it so store it as a variable:

char* val = "PU50,50;" ;

Then I want the arduino to extract the first 2 letters, that is "PU" and store it as a separate variable, then go on and extract the first coordinate that is "50" and then the second coordinate "50" and store both of these as a separate variable. How can i do this?

Thanks!

The reprap project has a G-code interpreter for the arduino that would serve as a good starting point for this functionality.

http://reprap.org

Take a look at the C string library functions. strtok, strncpy and atoi would be useful in this case.

The technical term for this is parsing, use this as your start point:-