The error messages in the question state that the error is thrown at C:/Perl/lib/Term/ReadKey.pm line 362
and that use Term::ReadKey
appears at C:/Perl/lib/Term/ReadLine/Perl.pm line 65
.
However, the comments to the question indicate that you are trying to run this code in a CGI environment. Given that the purpose of Readline is to provide additional functionality when reading a line of input from a terminal[*], it makes no sense to use it in a CGI context and I'm not at all surprised that it doesn't work there.
According to metacpan, AI::ExpertSystem::Advanced does not depend on Term::ReadLine::Perl, nor do any of its dependencies. Term::ReadLine::Perl must be getting used by some other part of your code. To resolve this problem, locate that section of code (grep -ir readline /my/source/tree
) and change it to either not use Readline at all or to detect whether it is running on the command line or under CGI and only require Term::ReadLine::Perl
if it's on the command line.
Edit: Tracking back through your earlier questions on this issue, I see that you're creating your ExpertSystem instance with viewer_class => 'terminal'
, which causes it to use AI::ExpertSystem::Advanced::Viewer::Terminal, which "Extends from AI::ExpertSystem::Advanced::Viewer::Base and its main purpose is to interact with a (console) terminal." (emphasis mine) In order to make this work, you need to use a different viewer class which does not "interact with a (console) terminal". Unfortunately, a search of metacpan finds no other available viewers, so you'll need to either find one somewhere else (the author of AI::ExpertSystem::Advanced may know where you can get one for CGI) or write your own viewer class.
[*] From the Term::ReadLine::Perl5 documentation:
GNU Readline reads lines from an interactive terminal with emacs or vi editing capabilities. It provides as mechanism for saving history of previous input.
This package typically used in command-line interfaces and REPLs (Read, Eval, Print Loops).