Hi Grant,


Grant wrote:
I'm setting up the URL structure for my next website.  I'd love to
know what you guys think is the best way to analyze the URL in perl in
order to generate the resultant page correctly.  The URL structure
only has 2 variants:

/page-name.html
/page-name/1/2.html
...
P.S. The second variant above could be changed to the following if it
is better for analysis:

/page-name-1-2.html


It depends on what you plan to do. But if you are talking about web server design and not parsing URLs generated by someone else, you might consider a framework such as Mason.

As others have said in another thread, you have many options. But what made me think of it is due to this section of text:

http://www.masonbook.com/book/chapter-3.mhtml#TOC-ANCHOR-8

which would sway me to choose your first option with the directory structures. Of course, if you plan to use Mason, you'll need to read more than this section -- but I think the section explains well one way of doing things.

The obvious difference between your two choices is not just between "/" and "-", but with the former, you're organizing things into directories. That might have the added benefit of making easier backups (you can backup one subdirectory at a time).

In terms of URL analysis (i.e., you are analyzing a log file), then "/" might also be better since you might have "-" within "page-name". In fact, your example above has exactly that: /page-name-1-2.html

The first hyphen is part of a name, but it is the other two hyphens that are performing some kind of subdivision. In /page-name/1/2.html, what the hyphen and the slashes do is more clear, IMHO...

Ray



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to