<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head><body bgcolor="#FFFFFF" text="#000000">You can put a unary plus sign operator on the parens to tell perl that the parens don't belong to the print command. Also comes in handy when using map in certain cases. <br clear="none">
<br clear="none">
print +( ... )<br clear="none">
<br clear="none">
Cheers, <br clear="none">
--Tommy Butler<br clear="none"><br clear="none"><div class="gmail_quote">On Sep 11, 2014, Robert Flach <robert.flach@webtooldeveloper.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="moz-cite-prefix">Tommy,<br clear="none">
Run the code without the STDOUT, then run it with. It's a
simple trick to avoid having perl interpret the ternary grouping
parenthesis as print function delemiting parenthesis. TIMTOWDI:
You could also wrap the entire thing in parenthesis, you could
skip the ternary and do your printing in an if. You could move
the ternary to an assignment statement to $val just before
printing plain old $val (what I would probably normally do if I
weren't being creative), etc. But the STDOUT is definitely
required for the code as is ;-) <br clear="none">
<br clear="none">
<div class="moz-signature">Robert Flach<br clear="none">
<b>Web Tools</b><br clear="none">
</div>
On 9/11/2014 1:37 PM, Tommy Butler wrote:<br clear="none">
</div>
<blockquote cite="mid:fbf5fc12-a58a-4899-9fd6-d36f4f111560@internetalias.net" type="cite">
</blockquote>
"print STDOUT" ???????<br clear="none">
<br clear="none">
You did that. On purpose? <br clear="none">
<br clear="none">
This raises so many questions :-P<br clear="none">
<br clear="none">
-- Tommy Butler<br clear="none">
<br clear="none">
<div class="gmail_quote">On Sep 11, 2014, Robert Flach
<a shape="rect" class="moz-txt-link-rfc2396E" href="mailto:robert.flach@webtooldeveloper.com"><robert.flach@webtooldeveloper.com></a> wrote:
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="moz-cite-prefix">Well, it sounds like it was a fun
meeting. I'm sorry I missed it! I personally will
occasionally use the FizzBuzz test when interviewing
applicants though I usually use more complicated coding
challenges. Maybe I could share one or more of those
sometime as a "more advanced" challenge. In the meantime,
scroll down for my solution and for the things I look for
when evaluating a fizzbuzz...<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
#!/usr/bin/perl<br clear="none">
use strict;<br clear="none">
use warnings;<br clear="none">
my $x = 0;<br clear="none">
while($x++ < 100)<br clear="none">
{<br clear="none">
my $val = "";<br clear="none">
$val .= ( $x % 3 == 0 ) ? "fizz" : "";<br clear="none">
$val .= ( $x % 5 == 0 ) ? "buzz" : "";<br clear="none">
print STDOUT ( $val ? $val : "$x" ) . "\n";<br clear="none">
}<br clear="none">
Things I look for in a fizz buzz:<br clear="none">
1. (Dealbreaker) Is the code readable. (I have a pretty
loose definition of readable and it definitely doesn't
require comments, but if it's unintelligible it's a
dealbreaker )<br clear="none">
2. (Dealbreaker) Will it produce correct output barring any
minor syntax errors i.e. is the algorithm valid. <br clear="none">
3. If doing a separate test for fizzbuzz have they optimized
to a mod 15 check.<br clear="none">
4. Can they (with prompting if needed) make the leap to
realizing they can concat the two tests to produce the
combined value without a separate test<br clear="none">
5. If using real code: will it compile.<br clear="none">
6. If using real code: will it compile without errors or
warnings (e.g. for perl can I stick a use strict;use
warnings; at the top of it.<br clear="none">
<br clear="none">
Things I never care about in a fizzbuzz:<br clear="none">
1. Do they know the correct operator for modulus (as long as
they know modulus is possible)<br clear="none">
2. while vs for vs. foreach, variable initialization,
ternary vs. if, perl vs c vs (insert your favorite language
argument here)<br clear="none">
3. correct formatting of output (e.g. I don't mind if they
forget to newline it, nor do I give extra points for printf
)<br clear="none">
4. error handling, supporting input arguments, etc. (this is
an algorithm test, not a coding practices test and a coding
practices test is unsuitable for the time available)<br clear="none">
<br clear="none">
Things somewhat unrelated to fizzbuzz but discernible in
some way related to the fizzbuzz tests that I definitely
care about/give extra credit for.<br clear="none">
1. Do they confirm or clarify the requirements with me in
some way e.g. "When you say instead prints fizz buzz or
fizzbuzz do you mean that you don't want it to print those
numbers at all and only print the alternate text, or would
you like it to always print the numbers and print that in
addition for those meeting the requirements?" It doesn't
matter if their question is clearly answered in the
requirements as written, restating the requirements as a
question is a hugely valuable (and often undervalued)
developer skill.<br clear="none">
2. Similarly to number 1, do they ask questions about what I
want in the solution (e.g. all those things in numbers 2-4
under things I never care about above) I don't care about
those things (for the test; very different standard for
"real" code), but many people do, and I DO care about your
ability to realize that and your willingness to adjust your
style accordingly. <br clear="none">
3. I will always ask for some modification of the code
afterwards. I care a lot about how they respond to that
request, whether it is a request to make it do something
different, to change the styling, to comment it, etc. <br clear="none">
4. If using pseudo code does their pseudo code look like a
human language construction or is it just code with invalid
syntax. (Either way, once they are done I will almost
always ask for something that would compile/interpret
correctly in some language.<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<div class="moz-signature">Robert Flach<br clear="none">
<b>Web Tools</b><br clear="none">
</div>
On 9/11/2014 12:15 PM, Lisa Cloutier wrote:<br clear="none">
</div>
<blockquote cite="mid:CAGX=xVThw3A7NYxcR8V3Bq8zvenmx7bZJUAZyRNe4xRyiBobBQ@mail.gmail.com" type="cite">
<div dir="ltr">
<div>
<div>Solution below:<br clear="none">
</div>
<div><br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
my $x = 1; <br clear="none">
<br clear="none">
while ($x <= 100)<br clear="none">
{<br clear="none">
if (($x % 3 == 0) && ($x % 5 == 0))<br clear="none">
{<br clear="none">
print "FizzBuzz\n";<br clear="none">
}<br clear="none">
elsif ($x % 3 == 0)<br clear="none">
{<br clear="none">
print "Fizz\n";<br clear="none">
}<br clear="none">
elsif ($x % 5 == 0)<br clear="none">
{<br clear="none">
print "Buzz\n";<br clear="none">
}<br clear="none">
else<br clear="none">
{ <br clear="none">
print "$x\n";<br clear="none">
}<br clear="none">
$x++;<br clear="none">
}<br clear="none">
<br clear="none">
</div>
I minorly "cheated" in that I didn't know the sign in
Perl for "mod" but had read Bob's email previously
(before learning about the challenge) and realized what
he was doing with the % sign. Had I been in an
interview I probably would have used every special
character in turn until I figured out the symbol for
mod. <br clear="none">
<br clear="none">
</div>
So I guess I can "program my way out of a wet paper bag"
as this <a shape="rect" moz-do-not-send="true" href="http://c2.com/cgi/wiki?FizzBuzzTest">website</a>
proclaimed about the FizzBuzz test. <br clear="none">
</div>
<div class="gmail_extra"><br clear="none">
<div class="gmail_quote">On Thu, Sep 11, 2014 at 11:42 AM,
John Fields <span dir="ltr"><<a shape="rect" moz-do-not-send="true" href="mailto:wigthft@gmail.com" target="_blank">wigthft@gmail.com</a>></span>
wrote:<br clear="none">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p dir="ltr">Firstly, I want to thank John Dexter for
his Docker presentation, showing how to encapsulate
a Mojolicious Web server and application for easy
deployment. He got what all presenters get, a free
dinner and that warm afterglow from making the world
a better place (with more Perl in it). :)</p>
<p dir="ltr">I challenged the attendees last night to
do the FizzBuzz program. We even had one programmer
in attendance that had been asked to do it on a job
interview the previous day! We were one day late
for him, but hopefully not for you..</p>
<p dir="ltr"><a shape="rect" moz-do-not-send="true" href="Http://rosettecode.org/wiki/FizzBuzz" target="_blank">Http://rosettecode.org/wiki/FizzBuzz</a></p>
<p dir="ltr">Don't cheat.. Yourself. Do it from
scratch before looking at other's solutions. We
will pick 2 more, with increasing difficulty with
one per week. Also new member Andy Sohn will offer
a short challenge and demonstrate answers live at
the next Mongers.</p>
<p dir="ltr">So send in your code, and be as creative
as you can! TIMTOWTDI is a strength after all. :)</p>
<p dir="ltr">Cheers,<br clear="none">
John and Tommy </p>
<br clear="none">
_______________________________________________<br clear="none">
Dfw-pm mailing list<br clear="none">
<a shape="rect" moz-do-not-send="true" href="mailto:Dfw-pm@pm.org">Dfw-pm@pm.org</a><br clear="none">
<a shape="rect" moz-do-not-send="true" href="http://mail.pm.org/mailman/listinfo/dfw-pm" target="_blank">http://mail.pm.org/mailman/listinfo/dfw-pm</a><br clear="none">
<br clear="none">
</blockquote>
</div>
<br clear="none">
</div>
<br clear="none">
<fieldset class="mimeAttachmentHeader"></fieldset>
<br clear="none">
<pre wrap="">_______________________________________________
Dfw-pm mailing list
<a shape="rect" class="moz-txt-link-abbreviated" moz-do-not-send="true" href="mailto:Dfw-pm@pm.org">Dfw-pm@pm.org</a>
<a shape="rect" class="moz-txt-link-freetext" moz-do-not-send="true" href="http://mail.pm.org/mailman/listinfo/dfw-pm">http://mail.pm.org/mailman/listinfo/dfw-pm</a>
</pre>
</blockquote>
<br clear="none">
<hr><br clear="none">
Dfw-pm mailing list<br clear="none">
<a shape="rect" class="moz-txt-link-abbreviated" href="mailto:Dfw-pm@pm.org">Dfw-pm@pm.org</a><br clear="none">
<a shape="rect" moz-do-not-send="true" href="http://mail.pm.org/mailman/listinfo/dfw-pm">http://mail.pm.org/mailman/listinfo/dfw-pm</a><br clear="none">
</blockquote>
</div>
<br clear="none">
-- Sent with <b><a shape="rect" moz-do-not-send="true" href="https://play.google.com/store/apps/details?id=com.onegravity.k10.pro2">K-@
Mail</a></b> - the evolution of emailing.
<br clear="none">
<fieldset class="mimeAttachmentHeader"></fieldset>
<br clear="none">
<pre wrap="">_______________________________________________
Dfw-pm mailing list
<a shape="rect" class="moz-txt-link-abbreviated" href="mailto:Dfw-pm@pm.org">Dfw-pm@pm.org</a>
<a shape="rect" class="moz-txt-link-freetext" href="http://mail.pm.org/mailman/listinfo/dfw-pm">http://mail.pm.org/mailman/listinfo/dfw-pm</a>
</pre>
<br clear="none">
<p style="margin-top: 2.5em; margin-bottom: 1em; border-bottom: 1px solid #000"></p><pre class="k10mail"></pre><hr><br clear="none">Dfw-pm mailing list<br clear="none">Dfw-pm@pm.org<br clear="none"><a shape="rect" href="http://mail.pm.org/mailman/listinfo/dfw-pm">http://mail.pm.org/mailman/listinfo/dfw-pm</a><br clear="none"></blockquote></div><br clear="none">-- Sent with <b><a shape="rect" href="https://play.google.com/store/apps/details?id=com.onegravity.k10.pro2">K-@ Mail</a></b> - the evolution of emailing.</body></html>