What they're trying to do is to get seperate the file from the end of the URL, so if the URL is 'http://www.wherever.com/whee/index.html' then $Dir should end up with 'http://www.wherever.com/', and $File as 'whee'
He's trying to do this by matching 'any number of any character' (The (.*) part) followed by a literal / (The \/ part), and then any number of characters which aren't / (The.. err.. ([^\/]*) part. The reason it doesn't get the 'whee' is because it's not actually anchored at the end of the regexp, which I think could cause you some fun bugs in itself with HTML files which aren't in document root..
Ugly ugly ugly! When you're rewriting this have a look at URI::URL which has methods for handling URI manipulation in a nice way.
Update: For some reason my brain read this as handling URLs.. guess this is a good argument for comments. Use the module Roik recommends below if it is files. Sorry
In reply to Re: Perl string matching
by Molt
in thread Perl string matching
by wizard341
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |