in reply to Hacking Debugger bugs connected to $^D

It isn't a bug. It is the feature of Perl where the last statement executed defines the return value. "sub foo {}" doesn't count as a run-time statment.

If you want "sub foo {}" to give back an empty list, then the solution is simple:

$ say '$^D=$^D; sub foo {}' 0 $ say '$^D=$^D; (); sub foo {}' $

- tye        

Replies are listed 'Best First'.
Re^2: Hacking Debugger bugs connected to $^D (())
by LanX (Saint) on Apr 25, 2013 at 01:47 UTC
    > "sub foo {}" doesn't count as a run-time statment.

    Ah I see! Now this explains why wrapping with do {... } helps.

    > $ say '$^D=$^D; (); sub foo {}'

    Good idea! I'll do that, thanks!

    Cheers Rolf

    ( addicted to the Perl Programming Language)