Heh. Your regex's are the problem.

First off, you should be use some sort of HTML parser. What if my HTML file is of the form:

<TITLE> Blahblah </title>
You'd never find "Blahblah".

Secondly, the fix you're looking for is

if ($line =~ /<TITLE(\w+)<\/TITLE>/i) ---- if ($line =~ m#<TITLE>(\w+)</TITLE>#i)
Note the backslash in front of the slash for the first one and the different regex delimiters for the second.

I have no idea what you're trying to do in your second regex. Why are you looking for the end of line with '$' before your line is done?

Also, use indentation. Your code should look something like:

use File::Find; sub wanted { if( -f $_ = '*.htm* ) { open ( F, $_ ) or die $/, $/; while( defined( $line = <F> ) ) { if($line =~ /<TITLE>(\w+)</TITLE>/i) { print "FILE = $_ and TITLE = $1\n"; } elsif( $line =~ /<title>(.*$)<title>/i) { print "FILE = $_ and TITLE = $1\n"; } } close F; } } find( \&wanted, "." );
See how much easier that is to read?

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.


In reply to Re: Finding data by dragonchild
in thread Finding data by Anonymous Monk

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.