Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: A better way? Extracting filename from url

by moodster (Hermit)
on Jan 14, 2002 at 17:01 UTC ( [id://138558]=note: print w/replies, xml ) Need Help??


in reply to Re: A better way? Extracting filename from url
in thread A better way? Extracting filename from url

It works, but I guess you've also got to consider the possibility that the URL will contain query parameters, like this: http://www.site.com/dir/file.html?param1=val1&param2=val2

So a second substitution (I'm sure you can do it with a lookahead assertion or similar, but that seems a bit overkill) is probably in order:

$file =~ s/\?.*//;

Cheers,
-- moodster

Replies are listed 'Best First'.
Re: Re: Re: A better way? Extracting filename from url
by Gerard (Pilgrim) on Jan 15, 2002 at 02:23 UTC
    Moodster has a good point. Thanks all for your comments. To be honest I had not even considered the possiblity of query paramters, which is very silly of me. But hey, it was late. Anway, I can now look at this again a bit later on.
    I am constantly amazed and impressed with the good nature and high value of comments that come out of this site.

    Regards,
    Gerard
    The caffeine addict (now sufficiently supplied).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://138558]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-26 06:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found