use strict 'no unwrapped candy'; use warnings 'look out for cars'; use constant HOME_BY => '8:00'; use constant CAN_EAT_TONIGHT => 1; sub halloween { my $self = shift; my $costume = shift or die "Can't have Halloween without a costume +!"; $self->put_on($costume) or die "Costume doesn't fit, choose anothe +r one"; my @houses = $self->neighorhood->houses; my $is_dark_out = 0; while ( ! $is_dark_out && @houses ) { my $house = shift @houses; next if $house->owned_by eq 'stranger' || ! $house->light_on; $self->approach($house) or do { warn "House is too scary"; next; } my $rc = $house->knock(); if ($rc =~ /^tr(ick|eat)$/) { $self->candy->add($rc) if $rc->wrapped; } else { push @{ $self->jerks_i_know }, $house; $self->tp($house) unless $self->mom->watching; } $is_dark_out = 1 if $self->watch->time() > HOME_BY && ! $self- +>beg_for_more_time; } $self->approach($self->home) or die "Mommy! I'm lost"; $self->take_off($costume); my $num_eaten = 0; # note - should re-factor into separate method to be portable to o +ther holidays, # but I'm busy eating sweet, sweet chocolate. EAT_CANDY: while (1) { my $piece = shift @{ $self->candy }; $self->eat($piece); $num_eaten++; if ( $self->mom->watching && $num_eaten > CAN_EAT_TONIGHT ) { # note - bug. This method always returns 0. last if ! $self->beg_for_one_more_piece; } } if ($num_eaten > 5) { sleep $self->watch->delta($self->watch->time, "2am"); $self->wake_up; $self->throw_up; goto EAT_CANDY; } if ( @{ $self->candy } ) { goto EAT_CANDY; } return $self->wait_for("christmas candy"); }

In reply to Perloween by jimt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.