CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
use cgi to parse a url?



Jun 28, 2000, 5:49 PM

Post #1 of 3 (1550 views)
use cgi to parse a url? Can't Post


I'm trying to figure out how to parse a url and return just the filename. For example, take the following url:


and return the value of ""

This needs to be a dynamic script that removes the urls, I have thousands of different urls to parse, so it can't just be set to remove the line. I know I read about how to do this, but I can't remember where and I appreciate anyone who can tell me how or point me in the right direction.


Kevin Johnson


Jun 28, 2000, 6:54 PM

Post #2 of 3 (1550 views)
Re: use cgi to parse a url? [In reply to] Can't Post

$url = "";
($file) = $url =~ m/([^\/]*)$/;

This assumes that if the URL is "" you're only interested in "".


Jun 28, 2000, 7:10 PM

Post #3 of 3 (1550 views)
Re: use cgi to parse a url? [In reply to] Can't Post

Thanks a lot... That was Exactly what I was looking for!

I'm going to use it on my software website to allow users to search for other download sites on ftp sites like fastftp, but I needed just the filename to do so.

Kevin Johnson


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives