LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

Is there a way to generally enable pragmas like use feature qw// in the perldebugger (used as a shell)?

perl -dE0 doesn't work, using a -M switch neither does.

Every line in perldb has it's own scope

so   DB<1> use feature "say"; say "huhu"

won't last.

The only possibility I can think of is using one of these "automatic commands" in front of each line.

¹)

Cheers Rolf

1) nope, neither! :(

Replies are listed 'Best First'.
Re: Convenient way to use 5.10 features in perldebugger?
by james2vegas (Chaplain) on Aug 15, 2010 at 17:29 UTC
    Or,
    1. copy perl5db.pl from your PERL5LIB to either somewhere in PERL5LIB or the current directory, with a different name, say myperl5db.pl
    2. Edit myperl5db.pl to have use feature ':5.10'; (or just 'state', or just 'say') on the first line.
    3. Set the environment variable PERL5DB to "BEGIN { require 'myperl5db.pl' }"

    Now perl -de0 will let you the new features.
      Thanks, good suggestion to generally enable all features! :)

      Actually I was looking for a switch to change interactively on demand, which doesn't include changing the source ... still grateful for any suggestions! :)

      Cheers Rolf

        Well, it isn't really changing the source, just having a local version of it, and if you have it in your PERL5LIB, enabling or disabling it is just a matter of setting or unsetting PERL5DB. Also worth noting is this is not limited to just enabling 'features' but you can add modules you use a lot in debugging (Data::Dumper, YAML, JSON, etc), or subs you write yourself.
Re: Convenient way to use 5.10 features in perldebugger?
by BrowserUk (Patriarch) on Aug 15, 2010 at 17:24 UTC

    Why use say when p or x are shorter still? (//= also works):

    c:\test>perl -de1 Loading DB routines from perl5db.pl version 1.32 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(-e:1): 1 DB<1> p 'huhu' huhu DB<2> $a //= 'fred' DB<3> p $a fred DB<4> x $a 0 'fred' DB<5>

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      say is an example, actually I try to experiment with state.

      But using state as an example is much more complicated, such that people on the CB didn't understand when I said "Thanks but doesn't work"!

      With say it's obvious!

      Cheers Rolf