Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Last night I was dreaming about the project I'm working on. so what? standard stuff. The project is all perl. No big deal, this is a perl site ...

But here's the really worrying bit: I woke up because part of my brain said "That code will never work. You need to ..." and then the debugging process woke up within me and my full consciousness returned pondering map{} and regexes and then I couldn't go back to sleep.

You know you're in for trouble when you start wondering whether

for (my $i=1; $i<=10000; $i++) { my $s = Sheep->new($i); $gate->through($s); }
would be more efficient written using an array like this:
my @herd; for (1..10000) { push @herd(Sheep->new($_)); } $gate->through(\@herd);
and then worrying whether you'd do even better to one line the whole thing
$gate->through(Sheep->new($_)) for (1..10000);
and then you wonder whether you couldn't fork() cunningly so that part of you is running Sheep->new($_) while another part is doing the gate->through($previous_sheep) bit. And then you wake up screaming because you still haven't figured out how to get windows to fork properly...

And we try again

$me =~ s!wide awake!fast asleep!g;
no hang on maybe I need to use the /e modifier.
$me =~ s!wide awake!asleep(fast)!ge;
no no no that'll never work I need quotes
$me =~ s!wide awake!asleep('fast')!ge;
ANd maybe I'm not wide awake so how about
$me =~ s!(wide )?awake!asleep('fast')!ge;
or better
$me =~ s!(?:wide\s+)?awake!asleep('fast')!ge;


Enter any 47-digit prime number to continue.

In reply to Dreaming in Perl by dingus

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (3)
    As of 2019-10-19 02:50 GMT
    Find Nodes?
      Voting Booth?