in reply to Re: What?? delete chars.
in thread What?? delete chars.
None of which should stop the program with strict off."my" variable %action masks earlier declaration in same scope at test. +pl line 47 . Useless use of private variable in void context at test.pl line 40. Bareword "LOC" not allowed while "strict subs" in use at test.pl line +95. Bareword "LOC" not allowed while "strict subs" in use at test.pl line +97. Bareword "LOC" not allowed while "strict subs" in use at test.pl line +99.
use strict; use warnings; print "Welcome.\n"; print "This game will lead you through many perils \n" . "and dangers +that could lead to your death.\n"; print "ONLY THE STRONG WILL SURVIVE\n\n"; my $data; my $action; my @items= (); my $location = "hall"; my $health; my @acdata; my %action; 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; } sub actions{ my $data; my @actdata; my $location; my $action; $data, $location = @_; chomp($data); $data =~ tr/A-Z/a-z/; @acdata = split(/ /, $data); exists $action{$acdata[0]} and $action{$acdata[0]}->(); my %action = ( go => \&go($location, $data) , use => \&use($location, $data) , pickup => \&pickup($location, $data) , drop => \&drop($location, $data) , throw => \&throw($location, $data) , push => \&push($location, $data) , pull => \&pull($location, $data) , search => \&search($location, $data) , check => \&check($location, $data) ); return %action; } sub go{ my ($location, $data) = @_; $data = &chomp_data($data); my $locationdata = &locationdata("go", $location, $data); print $locationdata; return "ok"; } sub chomp_data{ my $data = @_; chomp($data); $data =~ tr/A-Z/a-z/; my @data = split(/ /, $data); shift(@data); return @data; } sub locationdata{ my ($action, $location, $data) = @_; open('LOC', $location) or die "Could not open area script $location.\n +" . "Please check if the file was deleted or +moved.\n"; while(<$location>){ my $start = index(LOC, $action); $start = $start++; my $finish = index(LOC, '>', $start); my $total = $finish - $start - 1; my $cmd = substr(LOC, $start, $total); my @cmdl = split(/:/, $cmd); my @all = split(/#/, @cmdl); my @a = ($all[0], $all[2]); my @b = ($all[0], $all[1]); my @c = ($all[2], $all[3]); if ($cmd eq " "){ my $noun = "You can't do that.($action, $data)"; return $noun; } else{ last; } } } sub data{ my $location = @_; open('LOC', $location) or die "Could not open area script $location.\n +" . "Please check if the file was deleted or +moved.\n"; while(<$location>){ my $info = $_; chomp($info); my $length = length($info); $length = $length - 2; my $data = substr $info, 1, $length; return $data; last; } }
If everything seems to be going well, you obviously don't know what the hell is going on.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: What?? delete chars.
by pfaut (Priest) on Jan 14, 2003 at 19:42 UTC |