« blib/lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Auto.pm
↑ Summary
blib/lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Basename.pm »
| 1 | # -*- coding: utf-8 -*- | ||
| 2 | # Copyright (C) 2011-2015 Rocky Bernstein <rocky@cpan.org> | ||
| 3 | use warnings; no warnings 'redefine'; no warnings 'once'; | ||
| 4 | |||
| 5 | package Devel::Trepan::CmdProcessor::Command::Set::Auto::Eval; | ||
| 6 | |||
| 7 | BEGIN { | ||
| 8 | my @OLD_INC = @INC; | ||
| 9 | use rlib '../../../../../..'; | ||
| 10 | use Devel::Trepan::CmdProcessor::Command::Subcmd::Subsubcmd; | ||
| 11 | @INC = @OLD_INC | ||
| 12 | }; | ||
| 13 | |||
| 14 | use strict; | ||
| 15 | use vars qw(@ISA @SUBCMD_VARS); | ||
| 16 | @ISA = qw(Devel::Trepan::CmdProcessor::Command::SetBoolSubsubcmd); | ||
| 17 | # Values inherited from parent | ||
| 18 | |||
| 19 | use vars @Devel::Trepan::CmdProcessor::Command::Subsubcmd::SUBCMD_VARS; | ||
| 20 | |||
| 21 | our $IN_LIST = 1; | ||
| 22 | =pod | ||
| 23 | |||
| 24 | =head2 Synopsis: | ||
| 25 | |||
| 26 | =cut | ||
| 27 | our $HELP = <<'HELP'; | ||
| 28 | =pod | ||
| 29 | |||
| 30 | B<set auto eval> [B<on>|B<off>] | ||
| 31 | |||
| 32 | Evaluate unrecognized debugger commands. | ||
| 33 | |||
| 34 | Often inside the debugger, one would like to be able to run arbitrary | ||
| 35 | Perl commands without having to preface expressions with C<print> or | ||
| 36 | C<eval>. Setting C<auto eval> on will cause unrecognized debugger | ||
| 37 | commands to be evaluated as a Perl expression. | ||
| 38 | |||
| 39 | If the expression starts with %, @, or $ the context will be set | ||
| 40 | to a hash, array or scalar accordingly. | ||
| 41 | |||
| 42 | Note that if auto eval is set, the message shown on type a bad | ||
| 43 | debugger command changes from: | ||
| 44 | |||
| 45 | Undefined command: "fdafds". Try "help". | ||
| 46 | |||
| 47 | to something more Perl-specific such as: | ||
| 48 | |||
| 49 | Unquoted string "fdasfdsa" may clash with future reserved word | ||
| 50 | |||
| 51 | One other thing that trips people up is when setting auto eval is that | ||
| 52 | there are some short debugger commands that sometimes one wants to use | ||
| 53 | as a variable, such as in an assignment statement. For example: | ||
| 54 | |||
| 55 | s /a/b/ # Note the space after the s | ||
| 56 | |||
| 57 | is not a Perl substitute command but a "step" command when 'auto eval' | ||
| 58 | is on because by default, C<s> is an alias for the debugger C<step> | ||
| 59 | command. It is possible to remove that alias if this causes constant | ||
| 60 | problem. Another possibility is to go into a real shell via the | ||
| 61 | C<shell> command. | ||
| 62 | |||
| 63 | =head2 See also: | ||
| 64 | |||
| 65 | L<C<show auto eval>|Devel::Trepan::CmdProcessor::Command::Show::Auto::Eval>, and L<C<eval>|Devel::Trepan::CmdProcessor::Command::Eval> | ||
| 66 | |||
| 67 | =cut | ||
| 68 | HELP | ||
| 69 | |||
| 70 | our $MIN_ABBREV = length('ev'); | ||
| 71 | use constant MAX_ARGS => 1; | ||
| 72 | our $SHORT_HELP = "Set evaluation of unrecognized debugger commands"; | ||
| 73 | |||
| 74 | unless (caller) { | ||
| 75 | # Demo it. | ||
| 76 | # require_relative '../../../mock' | ||
| 77 | # name = File.basename(__FILE__, '.rb') | ||
| 78 | |||
| 79 | # dbgr, set_cmd = MockDebugger::setup('set') | ||
| 80 | # $max_cmd = __PACKAGE__->new(dbgr.core.processor, $set_cmd) | ||
| 81 | # $cmd_ary = Trepan::SubSubcommand::SetMaxList::PREFIX | ||
| 82 | # $cmd_name = cmd_ary.join(' ') | ||
| 83 | # $subcmd = __PACKAGE__->new($set_cmd->{proc}, $max_cmd, $cmd_name); | ||
| 84 | # $prefix_run = cmd_ary[1..-1] | ||
| 85 | # $subcmd->run(prefix_run); | ||
| 86 | # $subcmd-.run(prefix_run, qw(0)); | ||
| 87 | # $subcmd->run(prefix_run, qw(20)); | ||
| 88 | # $subcmd->summary_help(name); | ||
| 89 | |||
| 90 | # print '-' x 20; | ||
| 91 | # print $subcmd->save_command | ||
| 92 | } | ||
| 93 | |||
| 94 | 1; |