Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I was talking to our admin the other day and I looked into my boss’s office and noticed that his keys were gone but his notebook was on his desk which usually means he is either at lunch or gone for the day.
Since it was well after lunch-time I turned to our admin and said “so Mark is gone for the day?” and she was amazed and wanted to know how I knew that. So I started explaining the relationship of Mark’s notebook and keys being present or not to his location and I started thinking since I am just beggining to learn, how would I do this in perl? I ended up coming up with the following silly piece of code.

DrManhattan asked my why I used local $keys; and I pointed out that the idea was to determine if his keys or notebook were present…or local ;-) Thanks to DrManhattan for his assistance in making this actually run

#! /usr/bin/perl use Time::Object; my $time = localtime; my $boss="Mark"; local $keys; local $notebook; my $lunch = 1 if ($time->hour >12 and $time->hour <13); if ($keys and $notebook) { print "$boss is in the building but likely in the restroom \n" +; } elsif ($keys and !$notebook) { print "$boss is likely in the building and in a meeting n"; } elsif ($notebook and !$keys) { if ($lunch) { print "$boss is likely gone for lunch \n"; } else { print "$boss is likely gone for the day \n"; } } elsif (!$keys and !$notebook) { print "$boss is likely at an off-site meeting and may not retu +rn \n"; } else { print "I really don't know where $boss is as he appears to be +once again defying all logic \n"; }

In reply to Where is the boss? by phydeauxarff

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (15)
    As of 2014-07-30 17:26 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (237 votes), past polls