I have been rewriting or more rather porting the some ruby debuggers I've written to Perl. See Devel::Trepan.
In doing this I've been rethinking how evaluation of input should work and it strikes me that the same issues are relevant for Devel::REPL.
So let me describe how things work in Devel::Trepan and solicit your opinions.
Let's first start with the eval command. Think of it as sort of like "p" or "x" in perl5db. But on closer inspection these commands work a bit differently.
A fundamental fact of Perl is that a subroutine can query whether it was called in a scalar or an array context. So that suggests one needs two different kinds of eval for each context. The eval command allows for a suffix '@' or '$' to specify which context to evaluate to. In fact it's even more complicated than that. Like gdb, the debugger saves return values in a global to make it possible to use the results of that evaluation subsequently. So there are is also a hash context and suffix '%', and what that does is prepend "%hash_var = ..." to the expression typed.
When no suffix is given, we also look at the leading character of the text entered and if there is a sigil '@', '%', or '$' we use that for the "context". Of course this could be wrong, for example eval @ARGV == 0 is a scalar even though the leading character of the text is '@'. But I maintain that one could rewrite this as "eval 0 == @ARGV" or "eval scalar @ARGV == 0" or put in an explicit sigil "eval$ @ARGV == 0". So it doesn't strike me that this is too constraining and I think it is a useful heuristic. But what do you think?
One couple of last things. Above, I said there is an "eval" command. although that is correct, things are a little more complicated in order to make things work more simply in the usual case. The debugger has an "auto evaluation" mode and that is turned on by default. When you type something that isn't a debugger command, the text is automatically considered an "eval" command and sigils are checked to determine the default type. And to reduce typing, by default I have aliases of eval$, eval% and eval@to $, % and @ respectively. So above where write eval$ @ARGV == 0 you could also write $ @ARGV == 0.