Well ill give you guys the whole function im using
sub finder { @text = ""; $wordMatchFilePosition; $number = 0; $currentFilePosition; $lastPushed = space; $tagCount = 0; $quoteCount = 0; $loopcount = 0; if (!-d $File::Find::name) { open FILEHANDLE, "<$File::Find::name"; $size = -s $File::Find::name; $_ = ''; read FILEHANDLE, $_, $size; #on our first match, store the text behind and after the #word so the user can see a short desciption of why the #word appeared $file = $File::Find::name; if(!excludedDirectory()) { if(m/$key/i) { $wordMatchFilePosition = tell FILEHANDLE; seek FILEHANDLE, -1700, 1; $currentFilePosition = tell FILEHANDLE; for($loopcount = 0; $loopcount < 3000 && $currentFilePosition +!= $wordMatchFilePosition+700; $loopcount++) { $tempText = getc FILEHANDLE; #if we find the begining of the tag, increment the counter #dont add the text until we are back to 0 on the counter #(meaning were not in HTML commands) if($tempText eq "<") { $tagCount++; } #because were moving back an arbitrary number of character +s, #we might land in the middle of an HTML statement, therefo +re #if we hit a closing tag without having a begining tag #it should be safe to just ignore it elsif($tempText eq ">" && $tagCount > 0) { $tagCount--; } #More filtering of HTML elsif($tempText eq " \" ") { if($quoteCount == 1) { $quoteCount = 0; } else { $quoteCount = 1; } } #make sure were not reading HTML commands, the thing were +getting #is comprised of only letters, and were not trying to read + at the end #of the file, if its a space, and the last thing we pushed + on the text #was a letter, then its safe to assume that was the end of + a word #we are also filtering out numbers, because they are + used more with #defining pages then the actual content, we also dont want + things with _ #in it because its used for naming frames elsif($tagCount == 0 && $quoteCount == 0 && !eof FILEHAND +LE && $tempText =~ /(\b[A-Za-z]+\b)/ || $tempText =~ /^\s/ +&& $tempText ne "_") { if($lastPushed eq "character" && $tempText =~ /^\s/) { push(@text," "); $lastPushed = "space"; } else { push(@text,$tempText); $currentFilePosition++; $lastPushed = "character"; } } } print @text; print "\n"; } $number++ while/^${key}/g; close FILEHANDLE; $file = $File::Find::name; $length = length ($base_address) + 1; $file =~ /^.{${length}}(.*)/; if ($number) {$hash{$1} = $number} }#end if(!excludedDirectory()) } }
Before i get into explaining, i looked at the HTML parser, and it was a bit more complicated then i was willing to invest time in. I just made my own, and it seems to catch most of the html. So what i do is call this subroutine and finds the match. Which works, im sure of it. Then i just run around that match taking off byte by byte and making sure that its not HTML. Then i just put it into an array, if i found a space insert it only if the last character i inserted with a letter. The result is something like this: joint venture The Chinese government certification process for the joint venture and the new company name should be completed later this summer its not perfect, but its "good enough" for what i want to do, and thats show people what they will see when they click on that link.

In reply to Re: Re: Files! Reading specific parts by wizard341
in thread Files! Reading specific parts by wizard341

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.