while(1) { print "\nPlease select the catergory of results that you wish to see;\n\n\t1. first \n\t2. second \n\t3. third \n\t4. forth \n\t5. Others etc\n\t6. Exit program\n\n"; chomp($choice = ); if ($choice eq '6') { last; } #your code here }