From owner-freebsd-questions Mon Feb 4 7:49:56 2002 Delivered-To: freebsd-questions@freebsd.org Received: from indiana.tragus.org (ga-cmng-u1-c3b-89.cmngga.adelphia.net [24.53.98.89]) by hub.freebsd.org (Postfix) with ESMTP id 6431737B41E for ; Mon, 4 Feb 2002 07:49:35 -0800 (PST) Received: from chiroptera.tragus.org (chiroptera.tragus.org [192.168.42.2]) by indiana.tragus.org (8.12.1/8.12.1) with ESMTP id g14FnNe2001257; Mon, 4 Feb 2002 10:49:24 -0500 Received: (from jcej@localhost) by chiroptera.tragus.org (8.11.6/8.11.6) id g14FnNU30649; Mon, 4 Feb 2002 10:49:23 -0500 From: James CE Johnson Message-Id: <200202041549.g14FnNU30649@chiroptera.tragus.org> Subject: Re: [ale] perl File::stat question To: deepbsd@earthlink.net Date: Mon, 4 Feb 2002 10:49:23 -0500 (EST) Cc: ale@ale.org, kplug-list@kernel-panic.org, freebsd-questions@freebsd.org In-Reply-To: <20020204104417.A17219@sylvester.dsj.net> from "David S. Jackson" at Feb 04, 2002 10:44:17 AM X-Mailer: ELM [version 2.5 PL6] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG How about stat("$directory/$file") ? Also, shouldn't > print Tr( td( a({href=>"$dir/$file"}, "$title")), be > print Tr( td( a({href=>"$directory/$file"}, "$title")), > > I'm trying to stat a file > > $info = stat($file); > > and then set > $accesslast = $info->atime; > and > $created = $info->mtime; > > For some reason, stat($file) seems to be coming up null. When I > substitute another file, say stat("/etc/passwd"), $accesslast and > $created come up fine. Can you let me know what I'm doing wrong? > > > NOTE: I don't normally include the whole damn script, but if > there's anything *else* wrong with the code, please let me know > about that too, okay? I'm new at this stuff and I can always use > good advice! :-) > > ########### SNIP ############# > > > #!/usr/bin/perl -wT > > use Carp; > use CGI qw(:standard); > use File::stat; > use strict; > > > my $directory = '/var/www/compedge'; > my $url = 'http://sylvester.dsj.net'; > my $dir = 'compedge'; > > print header(), start_html("My ComputorEdge Articles"), > h1("Articles from I Don't Do Windows: "); > > print p( a({href=>"http://www.computoredge.com"}, "ComputorEdge > Magazine") . " has been gracious enough to give me and my > interest in Linux and UNIX some space in their magazine. Over > the months and years, my articles have accumulated to be a rather > regular part of the magazine. Hopefully, they can be of help for > anyone new to the free UNIXex. They are listed for your benefit > below."); > > print p("Please feel free to search for stuff in my articles " . > a({href=>"$url/$dir/search.html"}, "here"). " Note: I really > need to clean this script up! It's one of Matt's archive scripts > that can't pass muster with use strict or the -T switch. :-)"); > > print p("Meanwhile, you can simply " . > a({href=>"http://www.dsj.net/compedge/"}, "click here ") . "and > browse the directory of articles yourself. Find whatever seems > interesting to you."); > > # Start printing the table > > print "\n"; > print th( "Files:"), th( "Created:"), th("Last Accessed:"); > > opendir (DIR,"$directory"); > while (my $file = readdir(DIR)) { > if ($file =~ /\.html$/) { > open(FILE,"$directory/$file"); > while () { > chomp; > (my $line) = $_; > if ($line =~ //i) { > # only catches titles on one line...fix later... > (my $title = $line) =~ s#(<title>)(.*)()#$2#i; > > my $info = stat($file); > > my $created = $info->mtime; > my $accesslast = $info->atime; > > > print Tr( td( a({href=>"$dir/$file"}, "$title")), > td( "Created: $created"), td("Accessed last: $accesslast")); > next; > } > } > close FILE; > } > > } > > # close up the table > print "
\n"; > > close DIR; > > > print end_html(); > > ############### SNIP ################## > > TIA! > > > -- > David S. Jackson http://www.dsj.net > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > It's easy to get on the internet and forget you have a life > -- Topic on #LinuxGER > > --- > This message has been sent through the ALE general discussion list. > See http://www.ale.org/mailing-lists.shtml for more info. Problems should be > sent to listmaster at ale dot org. > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message