Perl Shell - A Solution

while ( ... ) { ... }

This while loop is the skeleton of the program. It gets a line of input, chops off the newline, processes it, prints the prompt and starts all over again. It exits when there is no next line of input either because a user typed an interactive end-of-file marker (control-D) or it hit the end of the script input.