SPUG: Opening files

Daniel V. Ebert debert at dusya.osd.com
Fri Jan 28 18:48:08 CST 2000


I'm trying to write some code to pull out the title from some HTML files.   
Below is the code I am using to get the filenames ... when $filename is a  
file in a subdirectory it dies (because it can't open the file).  I am  
guessing that this has something to do with the "/" character in the string  
$filename.

Any ideas?


#!/usr/bin/perl	
@ARGV = qw(.) unless @ARGV;
use File::Find;	

find sub {

	if ($File::Find::name =~ /^\.\/admin/ ||
	    $File::Find::name =~ /^\.\/deleted/) {} #skip files in subdirs

	elsif ($File::Find::name =~ /\.html/) { #only process .html files
		$filename = $File::Find::name;
		$filename =~ s/\.\///; #remove the ./ from start of $filename


	open (HTMLFILE, $filename) or die;
	@htmlfile = <HTMLFILE>;
	close (HTMLFILE);
	}
#DO OTHER STUFF
}

---
Dan Ebert
Seanet Internet Services
(206)343-7828

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list