<div dir="ltr">Hi All,<div><br></div><div>A student asked me for a perl solution to the problem at the bottom. </div><div><br></div><div>I went for both Ruby and Perl solutions, and here&#39;s some thoughts:</div><div><br>
</div><div>Perl sigils are cool and help understand the code. I really love them - BUT, I think they actually hurt readability on some cases. For example, I found ruby&#39;s <i>array.clone</i> far more readable than perl&#39;s [ @$array ]</div>
<div><br></div><div>Also, I found it easier to use subroutine refs in perl than in Ruby (not sure that&#39;s a good thing - code came out less readable).</div><div><br></div><div>OTOH, some things that surprised me in ruby:</div>
<div><br></div><div>Ruby has too many number types (I had to use .to_f function to get floating point division).</div><div>It&#39;s not possible in ruby to use a function before it is declared (forced me to write code at the bottom)</div>
<div>Ruby has no labels (making it hard to break from the outer loop)</div><div><br></div><div>All code (ruby + perl) is on a public gist:</div><div><a href="https://gist.github.com/2224433">https://gist.github.com/2224433</a></div>
<div><br></div><div>Your comments and thoughts are very welcomed,</div><div> Ynon</div><div><br></div><div><br></div><div><br></div><div>---</div><div><br></div><div><p style="margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:15px;line-height:20px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,sans-serif;color:rgb(64,64,64)">
Write a program that takes a list of numbers, a list of operators, and a goal; and tells the user which mathematical operations must be performed to reach the goal. For example, given the input:<br>numbers: 2, 4, 6, 8<br>
operators: +, -, *, /<br>goal: 25</p><p style="margin-top:0px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-style:initial;border-color:initial;font-size:15px;line-height:20px;font-family:&#39;Helvetica Neue&#39;,Helvetica,Arial,sans-serif;color:rgb(64,64,64)">
Program should produce the output:<br>sol = (((2 / 8) + 6) * 4)</p></div><div>----</div><div><br></div><div><br></div></div>