Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Bug in Devel::DProf?

by fletcher_the_dog (Friar)
on Aug 15, 2003 at 21:07 UTC ( [id://284255]=note: print w/replies, xml ) Need Help??


in reply to Bug in Devel::DProf?

In your second example they both are RIGHT. When calling parse(@_) recursively the new instance of parse creates its own @_. When you shift @_ in the recursive call you are NOT shifting the @_ of the parent caller. Try this:
#!/usr/bin/perl use strict; my $call = 0; parse(1,0); sub parse { my $curcall=++$call; print "My parameters: @_\n"; while (defined(my $number = shift)) { print "Number: $number from call $curcall\n"; parse(@_) if $number; } } OUTPUT: My parameters: 1 0 Number: 1 from call 1 My parameters: 0 Number: 0 from call 2 Number: 0 from call 1
Notice how the second printing of '0' is from call 1 and not call 2?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-19 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found