#!/usr/bin/perl use strict; use warnings; my $state = 1; my @exits = ("Major Motoko Kusanagi wishes you well!","Come back soon, ya hear?","Bah, coward!","Go with God.","Stellaaaaaa!","Namo Kuan Yin."); sub welcome { print "Welcome to my game! Do you want to move:\n\n"; print "North?\n"; print "South?\n"; print "East?\n"; print "West?\n\n"; } sub movement { while ($state == 1) { welcome(); print "<120/120hps 50/50mana 100/100mvs> "; chomp(my $move = ); if ($move =~ /^(north|south|east|west)$/i) { print "\nYou have moved $move.\n\n"; } elsif ($move =~ /^(halt|quit|exit)$/i) { print "\n$exits[rand @exits]\n\n"; $state = 0; } else { print "\nThat is not a valid option.\n\n"; } } } movement();