Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Hacking Debugger bugs connected to $^D (())

by tye (Cardinal)
on Apr 25, 2013 at 01:41 UTC ( #1030556=note: print w/ replies, xml ) Need Help??


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        


Comment on Re: Hacking Debugger bugs connected to $^D (())
Download Code
Re^2: Hacking Debugger bugs connected to $^D (())
by LanX (Canon) 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)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1030556]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2014-07-31 00:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (241 votes), past polls