print "Please enter a name.\n"; while(<>){ chomp; print "Hello, $_.\n"; print "Please enter another name.\n Or Ctrl-c to exit.\n"; }
There are two new perl shortcuts here. The 'spaceship' operator < > (the ``less than'' character followed by the ``greater than'' character) by default sets the perl scalar $_ to a line of text entered from the terminal. The line of text coming in from the terminal has a newline at its end. The function 'chomp' takes a string and cuts a newline character off the end.