eoin has asked for the wisdom of the Perl Monks concerning the following question:
You see its a fairly simple array pattern, you have you command on the left and the result on the right. I want to search through the array for the correct command and then assign the result to a variable called $location for examples sake, and if it doesn't find the command return an error message. I know that its probrably simple but I'm lost. Thanks.@array = ( 'north#library , 'south#kitchen', 'east#hallway')
Thanking you in advance.###main.pl use actions; use subs; print "Welcome to watever.\n"; print "This game will lead you through many perils and dangers that co +uld lead to your death.etc etc \n"; print "ONLY THE STRONG WILL SURVIVE"; my $data = "whatever" ; my $action; my @items= (); my $location = "hall"; my $health = "full"; &main($data, $location); sub main{ my( $data, $location ) = @_; while(<1>){ $data = &data($location); print $data; print "\n\n"; print "What do you want to do?? \n"; print "(type h for help.)\n"; print "Do what??\\: "; my $action = <>; my $noun = &action($action, $location); print $noun; } }
If everything seems to be going well, you obviously don't know what the hell is going on.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: array games??
by gjb (Vicar) on Jan 19, 2003 at 22:36 UTC | |
|
Re: array games??
by BrowserUk (Patriarch) on Jan 19, 2003 at 22:49 UTC | |
|
Re: array games??
by graff (Chancellor) on Jan 20, 2003 at 03:55 UTC | |
|
Re: array games??
by JamesNC (Chaplain) on Jan 20, 2003 at 05:48 UTC | |
|
Re: array games??
by Pardus (Pilgrim) on Jan 20, 2003 at 03:51 UTC |