"...it is still against my sense of economy or ecology"

Yes sure. But as i wrote:

"...less or more useful little hints"

IMHO it wasn't a bad idea to point the OP to $.

"...The test is pretty fast and has probably relatively limited impact of performance"

So let us compare:

#!/usr/bin/env perl use strict; use warnings; use Benchmark qw ( :hireswallclock cmpthese timethese ); our $file = qq (huge.file); our $amount = 1_000_000; sub karl { our ( $file, $amount ); open( my $in, "<", $file ); while (<$in>) { next if $. <= $amount; 1; } close $in; } sub laurent { our ( $file, $amount ); open( my $in, "<", $file ); my $useless_header_line = <$in> for 1 .. $amount; while (<$in>) { 1; } close $in; } my $results = timethese( 10, { 'karlgoethebier' => 'karl', 'Laurent_R' => 'laurent', } ); cmpthese($results); __END__ karls-mac-mini:monks karl$ perl -e 'print qq(Lorem ipsum kizuaheli\n) +for 1..50_000_000;' > huge.file karl-mac-mini:monks karl$ ls -hl huge.file -rw-r--r-- 1 karl karl 1,0G 21 Feb 17:24 huge.file karls-mac-mini:monks karl$ wc -l huge.file 50000000 huge.file karls-mac-mini:monks karl$ ./1117372.pl Benchmark: timing 10 iterations of Laurent_R, karlgoethebier... Laurent_R: 65.9521 wallclock secs (63.43 usr + 2.34 sys = 65.77 C +PU) @ 0.15/s (n=10) karlgoethebier: 127.837 wallclock secs (124.90 usr + 2.55 sys = 1 +27.45 CPU) @ 0.08/s (n=10) s/iter karlgoethebier Laurent_R karlgoethebier 12.7 -- -48% Laurent_R 6.58 94% --
"...relatively limited impact of performance"

This is relative. It is like it is ;-)

Thanks for your reply and best regards, Karl

«The Crux of the Biscuit is the Apostrophe»


In reply to Re^3: script assistance please by karlgoethebier
in thread script assistance please by perlnobie

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.