Laius, Oedipus's father is one perl program:
#!perl -w my $jocasta = '/dev/jocasta'; # laius marries jocasta # i reckon tis his kingdom the there roads are in, so let's let him bu +ild them, to the point where he and oedipus meet open FH,">/home/laius/crossroad"; print FH "$$\n"; close FH; symlink("/home/laius/crossroad","/dev/path1"); symlink("/home/laius/crossroad","/dev/path2"); symlink("/home/laius/crossroad","/dev/path2"); # he open a named pipe to his wife if ( system('mknod', $jocasta, 'p') && system('mkfifo', $jocasta) ){ die "mk{nod,fifo} $path failed (maybe i have body odor?)"; } no strict; # the device was yet to be invented # i think this is obvious open STDOUT,">$jacosta"; my $stamina = times(); while(times()-$stamina < 40){ # starting to age, are we? close STDOUT; open STDOUT,">$jacosta"; } my $fertility = (20_000_000 + rand (110_000_000)) * 2 *(1+rand()); # a +pproximate sperm count # many different sperm cells! for (my $i = 1; $i < $fertility; $i++){ print "sperm variation ".(1_000_000_000 * rand() * rand() * rand() + * rand())."\n"; } close STDOUT; # we're done NOP: { sleep 10; # not a successful spouse redo NOP; } $SIG{__WARN__} = sub { oracle() };
Whilst Jocasta, Oedipus's mother, and the parent process is another:
#!perl INIT { # she reaches puberty, i guess open STDIN,"/dev/jocasta'"; # and at some point no strict; } @sperm = <STDIN>; @sperm = grep { $_ = not $_ } @sperm; # about half make it in @sperm = grep { $_ > .5 } @sperm; # weak ones die later @sperm = sort { $b <=> $a } # fittest are ahead @sperm = @sperm[0 .. int($#sperm / 2)]; # the weaker ones die still $winner = shift @sperm; # one makes it, and undef @sperm; #the rest die sleep(9 * 30 * 24 * 60 * 60); # approximately 9 months later give_birth('oedipus'); # later came oedipus and made 4 little buggers for (my $i = 1; $i <= 4; $i++){ @sperm = <STDIN>; @sperm = grep { $_ = not $_ } @sperm; # about half make it in @sperm = grep { $_ > .5 } @sperm; # weak ones die later @sperm = sort { $b <=> $a } # fittest are ahead @sperm = @sperm[0 .. int($#sperm / 2)]; # the weaker ones die stil +l $winner = shift @sperm; # one makes it, and undef @sperm; #the rest die sleep(9 * 30 * 24 * 60 * 60); # approximately 9 months later give_birth($i); } kill KILL => $$; # oh my! she found out! sub give_birth(){ return if fork; # error checking is like crying over spilt milk. if ($_[0] eq 'oedipus'){ chdir("/"); # oedipus is disassociated fork && exit; $^W = 1; sleep (30 * 12 * 30 * 24 * 60 * 60); # approximately 30 years +later local $SIG{__WARN__} = sub { oracle() } open FH,"/dev/path".(int(rand(3)+.5)); local $_ = <FH>; close FH; kill KILL => $_; chdir("/home/jocasta"); # and he too my $jocasta = '/dev/jocasta'; for ($j = 0; $j < 4; $j++){ # four of them if ( system('mknod', $jocasta, 'p') && system('mkfifo', $jocasta) ){ die "mk{nod,fifo} $path failed (maybe i have body odor +?)"; } no strict; open STDOUT,">$jacosta"; my $stamina = times(); while(times()-$stamina < 240){ close STDOUT; open STDOUT,">$jacosta"; } my $fertility = (20_000_000 + rand (110_000_000)) * 2 *(1+ +rand()); for (my $i = 1; $i < $fertility; $i++){ print "sperm variation ".(1_000_000_000 * rand() * ran +d() * rand() * rand())."\n"; } close STDOUT; } close STDIN; # and now he's blind } }
sorry about the line wraps, but i guess it's not that important... nothingmuch/nothingmuch@mac.com

In reply to Oedipus Rex by nothingmuch

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.