Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Caffeine and its delivery to monks in need

by broquaint (Abbot)
on May 15, 2002 at 11:17 UTC ( [id://166685]=perlmeditation: print w/replies, xml ) Need Help??

It is not an entirely uncommon practice in the CB to have discussions about the fact that the morning is not the most pleasant of times for some monks. This fact having been established it's not unsurprising when blunders occur and there is subsequent application of caffeine to said monk e.g

broquaint goes off for caffeine after realising that he was working on the wrong file for the past 3hrs

However for some reason or another after having mistaken ascendance for ascension when congratulating the ever-wonderful virtualsue on achieving pontiff-hood I idly remarked

<broquaint>
hmmm, that should be ascension (ascendance means something else entirely). cat /dev/caffiene > broquaint

Now that I had publicly demonstrated how everyone can acquire caffiene through their favourite command-line editor there was a request from Sinister for some caffiene of his own which lead to

<broquaint>
foreach my $monk (grep /wants caffiene/, @monks) { system("cat /dev/caffiene > $monk &") }

However demerphq was disapproving of this lacklustre solution and came up with

<demerphq>
tsk tsk, broquaint that's sooo inefficient ;-) /wants caffne/ && system "cat /dev/caffiene > $_ &" foreach @monks;

Which lead to further and more varied solutions[1] from fellow monks who too were concerned that each monk got their desired portion of caffeine

<rob_au>
broquaint, demerphq - that still won't work where a monk has a space in their nick - try ... /wants caffiene/ && system('cat', '/dev/caffiene', '>' . $_, '&') for @monks
Sinister thinks :
$monks{$_}->{caffeine}++ foreach(keys %monks);
<demerphq>
bah! $_->drinks(Hot::Beveridge->new(type=>'coffee',quality=>'high', origin=>'Jamaica', region=>'Blue Mountain')) foreach @monks ;-)
<Dog and Pony>
$monk->pour_coffee() while($monk->tired());
<broquaint>
system schmystem - foreach $monk (@monks) { open($mouth, "|$monk"); print $mouth while <CAFFIENE>; }

So can anyone else come up with a more efficient/varied/effective caffeine delivery system for the poor morning monks who are mere shells of programmers without their fix?

_________
broquaint

[1] cb chatter editted for the sake of brevity

  • Comment on Caffeine and its delivery to monks in need

Replies are listed 'Best First'.
Re: Caffeine and its delivery to monks in need
by FoxtrotUniform (Prior) on May 15, 2002 at 15:27 UTC

    Methinks that brother demerphq has the right idea, but an unnecessarily restrictive namespace: I'd prefer something like this:

    • Caffeine
      • Beverage
        • Hot
        • Cold
        • Intravenous
      • Foodstuff
        • Mint
        • Bean
        • Tablet

    So with that namespace in mind:

    connect(Caffeine::Beverage::Intravenous->new( "type" => "coffee", "roast" => "light", "strength" => "demitasse"), $monks{"FoxtrotUniform"}) or warn "Matt's going to be grumpy: $!\n";

    --
    :wq

Re: Caffiene and its delivery to monks in need
by Sinister (Friar) on May 15, 2002 at 11:35 UTC
    Not so elegant (in more then one way) as my $CB_post, but sufficient...
    splice(@$monk, $mouth, $#coffee, @coffee) foreach $monk ( grep {/wants_coffee/} @monks );


    er formait hyarya.
    "Field experience is something you don't get until just after you need it."
Re: Caffeine and its delivery to monks in need
by vladb (Vicar) on May 15, 2002 at 12:55 UTC
    Hehe, this would be my 'losy' attempt at serving coffee!
    for (grep {$_->is_early_tired() && $_->requires_coffee()} @cb_monks) { do { $_->consume(Hot::Coffee->new($_->get_coffee_prefs())); while ($_->more_coffee_wont_hurt()); }

    Note that I'm not a big expert on customer care ;).

    _____________________
    $"=q;grep;;$,=q"grep";for(`find . -name ".saves*~"`){s;$/;;;/(.*-(\d+) +-.*)$/;$_=["ps -e -o pid | "," $2 | "," -v "," "];`@$_`?{print"+ $1"} +:{print"- $1"}&&`rm $1`;print"\n";}
(wil) Re: Caffeine and its delivery to monks in need
by wil (Priest) on May 15, 2002 at 13:07 UTC
    ++broquaint

    I love this node! This really amused me how much this great community of Perl hackers are determined to make everything possible with Perl.

    I had to add to this thread, so here's my attempt:
    my $i = $caffeine_level; for ($i = 0; $i < 100; ++$i) { push (@monk_needs,$caffiene); }

    - wil

      my $i = $caffeine_level; for ($i = 0; $i < 100; ++$i) {

      The first assignment is useless, as $i's value is immediately overwritten. The loop is inefficient, as for simple loops like this, a Perlish loop is faster and easier to write: for (1..100). Yes, I changed it from 0..99 to 1..100, because 1..100 looks better and you're not using the iterator variable anyway.

      - Yes, I reinvent wheels.
      - Spam: Visit eurotraQ.
      

Re: Caffeine and its delivery to monks in need
by Rex(Wrecks) (Curate) on May 15, 2002 at 17:13 UTC
    A semi-OO way :)

    Called as: ./Caffeine.pl kenya_AA high am 10
    Here is the code:
    use IV::Caffeine ; my $favorite_poison = shift ; my $flowrate = shift ; my $time_of_day = shift ; my $groggy = shift ; if ($time_of_day ne "pm"){$time_of_day = "am" ;} while ($time_of_day eq "am" || $time_of_day = "pm") { my $leftarm = "InnerLeftElbow" ; my $rightarm = "InnerRightElbow" ; $injector = new IV::Caffeine(Poison => $favorite_poison, NeedleSize + => $flowrate) $injector->pierce_skin($leftarm) ; $injector->pierce_skin($rightarm) ; $injector->begin_flow ; if ($groggy >= 5) {$injector->increase_flow($leftarm, $rightarm) ;} }


    "Nothing is sure but death and taxes" I say combine the two and its death to all taxes!
Re: Caffeine and its delivery to monks in need
by artist (Parson) on May 15, 2002 at 14:28 UTC
    Hi,
    Would some one please tell me, why associate Caffeine with perl.

    After all, there is more than one way to achieve.

    Point of view
    of
    an artist.

      Supply your own list of vices:

      @foibles = qw( caffiene pizza ... ); foreach $monk (@perlmonks) { push @{ $monk->{toConsume} }, grep { exists $monk->{vices}{$_} } @foibles; }
      You are absolutely right! We musn't forget nicotine (in some cases that is) and pizza in this lovely thread!

      foreach $self ( keys %monks ) { $monks{$self}->{$_}++ foreach(qw(caffeine nicotine pizza)) }


      er formait hyarya.
      "Field experience is something you don't get until just after you need it."
        Surely you jest and mean:

        &smoke while (1);
        cancer SMiTZ
Re: Caffeine and its delivery to monks in need
by Juerd (Abbot) on May 15, 2002 at 17:00 UTC

    
    perl -MLWP::Simple -e'get "http://www.peppermints.com/"'
    
    Note: This is not intended as spam. I just like Penguin Mints.
    Disclaimer: I hereby disclaim all responsibility for caffeine overdoses.

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

      I would have to change that to
      perl -MLWP::Simple -e'get "http://www.peets.com/'
      My dream is to open a Peets out here in Ohio some day.
      ()-()
       \"/
        `                                                     
      
Moose Roast
by rhesa (Vicar) on Apr 15, 2007 at 00:57 UTC
    package PerlMonk::Fix; use Moose; extends 'PerlMonk'; augment 'productivity' => \&with_coffee; before 'breakfast' => \&serve_coffee; around 'lunch' => \&serve_coffee; after 'dinner' => \&serve_coffee; no Moose;
Re: Caffeine and its delivery to monks in need
by QwertyD (Pilgrim) on May 18, 2002 at 01:37 UTC
    $bloodstream = chomp(<COFFEEBEANS>);
    For once, a node about Java that's squarely on topic!
    (Please don't hurt me because I'm a punster.)
    How do I love -d? Let me count the ways...
Re: Caffeine and its delivery to monks in need
by newrisedesigns (Curate) on Jun 20, 2002 at 03:24 UTC

    half-tempted to make this work by prompting for a username and password...

    #!/usr/bin/perl -w use strict; use LWP::Simple; my $url = 'http://perlmonks.org/index.pl?'; my @usernames; my $xml = get("${url}node_id=15851"); my @ret = split(/\n/, $xml); @ret = grep(/\A\<user/, @ret); foreach (@ret){ /username="([\w\d\ \$\.\%\@\-]*)"/; push(@usernames, $1); } foreach (@usernames){ s/\s/_/g; print $_; get("${url}op=message&message=/msg\%20$_\%20Here's+some+coffee.+Enjoy. +"); }

    If anyone else wants to make it work... be my guest.

    John J Reiser
    newrisedesigns.com

Re: Caffeine and its delivery to monks in need
by Aristotle (Chancellor) on May 18, 2002 at 05:35 UTC
    push @{$_->{glass}}, pop @soda foreach @monk;
    ____________
    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-12-14 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (70 votes). Check out past polls.