Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Just Another Pricey Holiday

by ehdonhon (Curate)
on Feb 15, 2002 at 14:57 UTC ( #145687=note: print w/replies, xml ) Need Help??


in reply to Re: Just Another Pricey Holiday
in thread Just Another Pricey Holiday

I think your code is closer, but perhaps still a bit optimistic. Because the assignment of $some_play is in an until loop, it will continuously loop through and eventually get set (assuming that your randomizer has been seeded sufficiently so that it is possible for the whim to change).

However, I've found that often buy() can somehow get stuck in an infinite loop until everything crashes. Once you are stuck in the loop, control is never passed back so that $some_play can even be considered. This can crash in two ways. Either you'll get a heap overflow from the recursion, or the credit card will fail.

sub buy () { { $::not_a_good_night ||= rand; if ( $credit_card_balance > $credit_card_limit ) { die ( "Dog house tonight" ); } push @shopping_cart, shift(), shift(); buy(qw( more things )) if ( $::not_a_good_night > 0.3 ); }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://145687]
help
Chatterbox?
[chacham]: i'm reading an article on codepath.com and thee is a disturbing message on the bottom right that says, "Fork me on GitHub". Maybe i just have a dirty mind.
[choroba]: Check the ninja on perlbrew.pl
[chacham]: oh my...
[Corion]: choroba++ # fixed width
marto has a Dirty_Mind on vinyl
[Corion]: Heh. The upside of this phone call was at least commendations from my cow-orkers on how clam I stayed and how I always brought the topic back to my priorities and the established processes of $work (them only getting half of the conversation).

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2017-08-17 13:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (287 votes). Check out past polls.

    Notices?