in reply to Finding data

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.

Replies are listed 'Best First'.
Re: Re: Finding data
by Anonymous Monk on Feb 28, 2002 at 18:52 UTC
    I am still lost on why this isnt working. Please advise more.