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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



KingSky
Deleted

Jun 28, 2000, 5:49 PM

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

Hi,

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

"http://www.moochers.com/vbrun100.zip"

and return the value of "vbrun100.zip"

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 http://www.moochers.com/ 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.

Thanks!

------------------
Kevin Johnson
http://www.moochers.com/


dws
Deleted

Jun 28, 2000, 6:54 PM

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

$url = "http://www.moochers.com/vbrun100.zip";
($file) = $url =~ m/([^\/]*)$/;

This assumes that if the URL is "http://www.moochers.com/foo/bar.zip" you're only interested in "bar.zip".



KingSky
Deleted

Jun 28, 2000, 7:10 PM

Post #3 of 3 (741 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
http://www.moochers.com/

 
 


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

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