There is practically no difference between the two. Your benchmark is flawed, here is a correction (only the addition of delete $INC{'CGI.pm'}; is required):
use Benchmark 'cmpthese'; use CGI(); undef %CGI::; delete $INC{'CGI.pm'}; cmpthese( shift, { use => sub { eval "use CGI();"; undef %CGI::; delete $INC{'CGI.pm'}; return (); }, require => sub { eval "require CGI;"; undef %CGI::; delete $INC{'CGI.pm'}; return (); }, }); __END__ $$ perl eval.use.v.eval.require.pl -3 Benchmark: running require, use, each for at least 3 CPU seconds... require: 3 wallclock secs ( 3.09 usr + 0.13 sys = 3.22 CPU) @ 37 +.28/s (n=120) use: 3 wallclock secs ( 3.06 usr + 0.17 sys = 3.23 CPU) @ 37 +.11/s (n=120) Rate use require use 37.1/s -- -0% require 37.3/s 0% -- $$ perl eval.use.v.eval.require.pl -5 Benchmark: running require, use, each for at least 5 CPU seconds... require: 5 wallclock secs ( 5.14 usr + 0.14 sys = 5.28 CPU) @ 37 +.31/s (n=197) use: 5 wallclock secs ( 5.05 usr + 0.25 sys = 5.30 CPU) @ 37 +.19/s (n=197) Rate use require use 37.2/s -- -0% require 37.3/s 0% -- $$ perl eval.use.v.eval.require.pl 50 Benchmark: timing 50 iterations of require, use... require: 1 wallclock secs ( 1.30 usr + 0.03 sys = 1.33 CPU) @ 37 +.65/s (n=50) use: 1 wallclock secs ( 1.31 usr + 0.03 sys = 1.34 CPU) @ 37 +.23/s (n=50) Rate use require use 37.2/s -- -1% require 37.7/s 1% -- $$ perl eval.use.v.eval.require.pl 100 Benchmark: timing 100 iterations of require, use... require: 3 wallclock secs ( 2.61 usr + 0.06 sys = 2.67 CPU) @ 37 +.41/s (n=100) use: 2 wallclock secs ( 2.63 usr + 0.05 sys = 2.67 CPU) @ 37 +.43/s (n=100) Rate require use require 37.4/s -- -0% use 37.4/s 0% -- $$

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.


In reply to Re: Re: use vs. require in string eval? by PodMaster
in thread use vs. require in string eval? by lachoy

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.