Here are some tips if you don't want to use external tools. The key is to be lazy and defer as much work as possible. One simple thing you can do is
my ($filename, $rest) = split /,/, $_, 2; if (index($filename, $to_find) > -1) { my ($cms, $path, $size, $day, $time) = split /,/, $rest;
Going quite a lot further:
open(F, "+< $infile"); while (sysread F, $_, 32768) { $_ .= <F>; next unless /\Q$to_find\E/; # quickskip for(grep /^[^,]*?\Q$to_find\E/, split /\n/, $_) { ($filename, $cms, $path, $size, $day, $time) = split /,/; $href = "file:\\\\netd\\data".$path."\\$filename"; $href =~ s/\s/%20/g; $table .= "<TR><TD><A HREF=\"$href\">$path\\$filename</A><TD>$si +ze<TD>$day $tim +e</TR>"; } } close(F);
This greatly reduces the number of IO operations and restricts the heavy splittage to known matches.

I believe the following is an extra win, but I haven't benchmarked it.
open(F, "+< $infile"); while (sysread F, $_, 32768) { $_ .= <F>; next unless /\Q$to_find\E/; # quickskip while(/^([^\n,]*?\Q$to_find\E[^\n]*)/gm) { ($filename, $cms, $path, $size, $day, $time) = split /,/, $1; $href = "file:\\\\netd\\data".$path."\\$filename"; $href =~ s/\s/%20/g; $table .= "<TR><TD><A HREF=\"$href\">$path\\$filename</A><TD>$si +ze<TD>$day $tim +e</TR>"; } } close(F);
Beyond these tricks, you quickly get to the point of pretty much handrolling your own database engine..

Makeshifts last the longest.


In reply to Re: I need speed by Aristotle
in thread I need speed by Galen

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.