[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Reading/Writing JavaScript Array in Perl (redux)



> Well, if I am basically a self-learner with PERL.  If you have a better 
> way of getting directory information then tell me.  I think I am like you 
> -- get some code and then go from there though I am getting much better at 
> starting from scratch.  I really want to go OOP with Perl but just do not 
> have enough examples to get me started.  :)  Gotta love cgi-resources, 
> though.  Treasure-trove of information on Perl and CGIs. :)

Hmm. Doing some thinking on this.  Your method works sort-of (see below), 
but I'll have to trim the paths off, as all I need are the filenames.  I 
still have to read the files and do some regex to match 

<TITLE>[A-Za-z_0-9]</TITLE>

or some such.  Usually takes two or three stabs for me to get a regex 
right, but when it's done it's DONE.

Could just create a directory handle, or maybe chdir() and then glob() 
all the files within...  However, since I have your code in hand, and it 
works (sort-of), I see no reason to start fresh... yet.  At some point, 
when I have EVERYTHING up and working the way I like.  I'll toss it and 
start over (always a good idea to write one version just to throw away).  
I'm not near there yet.

glob() is rather limited in MacPerl.  Only * and ? are supported.  Not as 
bad as it seems.

<rant>
I don't do cgi stuff in Perl.  For me Perl is convenient for a range of 
general-purpose programming tasks.  Web-page pre-processing is a close as 
I get to cgi, which is to say NOT VERY. Perl is great for quick&dirty 
prototyping, and the UI stuff in MacPerl is developed enough to do actual 
FUNCTIONAL applications with it.  I've really no truck with folks who 
want to do all their interface stuff in say Perl/tk and then grouse 
'cause they don't have it on the Mac.  Use Perl/tk under Unix.  
Conditionally test for $^O, and eval 'use Mac::Windows' on the Mac.  
Conditionally test for $^O and eval 'use Win32::GUI' under Windows.  
Implement platform specifics as packages and place them in external files 
called with 'require'!  Sure it's extra work, but you get a NATIVE UI for 
each platform from a single code base!  Try THAT in any other language!  
CGI is IMESHO, is not the be-all and end-all of Perl.  That said, I know 
lots of people use it that way and more power to them!
</rant>

Oh, and the array items returned by stat() may not mean the same things 
under MacOS as they do under Unix.  For instance $atime is always equal 
to $mtime on the Mac. So line 38:

   if ($ACCTIME <= $MODTIME) {

always evaluates true.  Thus every file in the search path which 
otherwise matches our criteria gets included! Ouch! That's the WHOLE 
website!

Since this is generally aproppo the MacPerl list, I'm posting this back 
there. (See "MacPerl Power & Ease" ppg 296, with details on how stat() on 
the Mac is at variance with the Unix Perl.

Syntax checks okay, I assume it pro'lly runs fine on Unix (not a SAFE 
assumption, but I'm not aware of contrary evidence). Gonna have to recode 
for Mac.

Might be okay to limit the search to "default.*" and "news.*" files.  
(use wildcards instead of specifying .html, because ".html" is NOT a 
given at least on my server (even if that's what the end-user sees it 
as).  Those two are the most-frequently changed, and always contain 
site-wide links as a matter of course.  This avoids linking to archived 
files (which are still in the FLAT directory tree so as not to break 
links).  Since there are THREE directories with a "default.html" or 
equivalent file, and could potentially be more...

The resulting list of files is NOT the final output.  This is only a list 
of files to pass through the parser.  What I need to look for is the 
top-most (internal) links within each file, which because I lay them out 
that way, will always be the most recent additions.

Older files drop off the bottom of the page and are moved to "archive_*" 
files.  Doesn't make sense to link to anything in "research/default.*" as 
everything there is external to the site, and "taxy/default.*" is fairly 
static (programmer's wanted!).







# Brian McNett                                      Fungal Parataxonomy
# Webmaster, Staff Writer               Mycology Information (Mycoinfo)
#                              **The World's First Mycology E-Journal**   
# <mailto:webmaster@mycoinfo.com>            <http://www.mycoinfo.com/>
# First they ignore you. Then they laugh at you. Then they fight you.
# Then you win.                                     --Mohandas Gandhi


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org