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

The debugger and "use feature" are not playing together nicely in 5.14. Is there some special incantation needed?
perl -de 0 Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 0 + DB<1> use feature 'say' + DB<2> say "Goodnight, Gracie" String found where operator expected at (eval 26)[/honk/perl5.14.0/lib +/5.14.0/perl5db.pl:640] line 2, near "say "Goodnight, Gracie"" at (eval 26)[/honk/perl5.14.0/lib/5.14.0/perl5db.pl:640] line 2 eval '($@, $!, $^E, $,, $/, $\\, $^W) = @saved;package main; $^D = + $^D | $DB::db_stop; say "Goodnight, Gracie"; ;' called at /honk/perl5.14.0/lib/5.14.0/perl5db.pl line 640 DB::eval called at /honk/perl5.14.0/lib/5.14.0/perl5db.pl line 343 +6 DB::DB called at -e line 1 (Do you need to predeclare say?) at (eval 26)[/honk/perl5.14.0/lib/5.14.0/perl5db.pl:640] line 2 eval '($@, $!, $^E, $,, $/, $\\, $^W) = @saved;package main; $^D = + $^D | $DB::db_stop; say "Goodnight, Gracie"; ;' called at /honk/perl5.14.0/lib/5.14.0/perl5db.pl line 640 DB::eval called at /honk/perl5.14.0/lib/5.14.0/perl5db.pl line 343 +6 DB::DB called at -e line 1 syntax error at (eval 26)[/honk/perl5.14.0/lib/5.14.0/perl5db.pl:640] +line 2, near "say "Goodnight, Gracie""

Replies are listed 'Best First'.
Re: debugger versus say in 5.14
by salva (Canon) on May 16, 2011 at 13:50 UTC
    That happens because the debugger creates a new scope for every line run interactively.

    See #87412, and apply the patch attached there it you like!

      Patch works well, thanks!
      perl -de 0 Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 0 DB<1> say "Goodnight, Gracie" Goodnight, Gracie
        Although I like your patch, and will probably keep it, it is a bit ham-handed. As you say in the patch

        The attached patch enables all the features available in the running perl.

        I can be more selective if I use

        perl -Mfeature=say -de 0
        to arm just the feature(s) I'm after. It would be nicer still if there were some way to have finer control of the lexical scope created by the debugger (I am forever getting burned by cutting and pasting my $var = "something"; into the debugger, which is effectively ignored for the same reason you mentioned). But at least there are ways to use new features inside the debugger.

        Update: My mistake. That appears to work only because I already have your patch installed. It doesn't work with 5.12.1 without the patch.