<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On May 14, 2006, at 10:44 AM, Dave M wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I often use the same md5 subroutine in all my scripts for various</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">reasons. Recently I saw another way to read it in, and it appears to</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">be faster:</DIV></BLOCKQUOTE><BR></DIV><DIV><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV><SPAN class="Apple-style-span"><FONT class="Apple-style-span" face="Lucida Grande">The #1 rule of benchmarking is to pull out as much irrelevant stuff as you can.  For instance, the check for -d $file should be done outside of the benchmarked functions.  It's the same in both functions, and skew your results.  What if that check for the directory turns out to be 90% of the runtime in both cases?</FONT></SPAN></DIV><DIV><FONT class="Apple-style-span" face="Lucida Grande"><BR class="khtml-block-placeholder"></FONT></DIV><DIV><FONT class="Apple-style-span" face="Lucida Grande">Other than that, I don't see anything else to pull out, though.</FONT></DIV><DIV><FONT class="Apple-style-span" face="Lucida Grande"><BR class="khtml-block-placeholder"></FONT></DIV><DIV><FONT class="Apple-style-span" face="Lucida Grande">You might want to try this:</FONT></DIV><DIV><FONT class="Apple-style-span" face="Lucida Grande"><BR class="khtml-block-placeholder"></FONT></DIV><DIV style="font-family: Helvetica; "><FONT class="Apple-style-span" face="Lucida Grande">                my $slurp  = do { local $/; &lt;FH&gt; };</FONT></DIV><DIV style="font-family: Helvetica; "><FONT class="Apple-style-span" face="Lucida Grande">                my $md5sum = Digest::MD5::md5_hex($slurp);</FONT></DIV><DIV style="font-family: Helvetica; "><FONT class="Apple-style-span" face="Lucida Grande"><BR class="khtml-block-placeholder"></FONT></DIV><DIV style="font-family: Helvetica; "><FONT class="Apple-style-span" face="Lucida Grande">as</FONT></DIV><DIV style="font-family: Helvetica; "><FONT class="Apple-style-span" face="Lucida Grande"><BR class="khtml-block-placeholder"></FONT></DIV><DIV style=""><FONT class="Apple-style-span" face="Lucida Grande">                local $/;</FONT></DIV><DIV style="font-family: Helvetica; "><FONT class="Apple-style-span" face="Lucida Grande">                my $md5sum = Digest::MD5::md5_hex(&lt;FH&gt;);</FONT></DIV><DIV><FONT class="Apple-style-span" face="Lucida Grande"><BR class="khtml-block-placeholder"></FONT></DIV><DIV><FONT class="Apple-style-span" face="Lucida Grande">This removes the assignment of a local variable which you're then going to copy.</FONT></DIV><DIV><FONT class="Apple-style-span" face="Lucida Grande"><BR class="khtml-block-placeholder"></FONT></DIV><DIV><FONT class="Apple-style-span" face="Lucida Grande">xoa</FONT></DIV><DIV><FONT class="Apple-style-span" face="Lucida Grande"><BR class="khtml-block-placeholder"></FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-style-span">--</SPAN></DIV><DIV>Andy Lester =&gt; andy@petdance.com =&gt; www.petdance.com =&gt; <A href="AIM:petdance">AIM:petdance</A></DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR class="Apple-interchange-newline"></SPAN></SPAN> </DIV><BR></BODY></HTML>