Joined: 25 Jun 2004 Posts: 130 Location: Liverpool(home) or Derby(uni), UK votes: 3
Posted: Mon Jul 03, 2006 8:17 pm Post subject: Getting the filename of a web download?
I am trying to make a command that will send a random Msg+ Live! sound. My bot can send the sounds now, but there are lots and lots of sounds which are identified by their ID. You can download a random sound from the following site: http://sounds.msgpluslive.net/esnd/snd/random?catId=2
When you visit that site, it sends you a file, and the name of the file is the ID of the song. So what I need to do is not download the file, but see the filename that it is sent with. Is there a way I can do this? Ive looked at the LWP documentation on cpan and cant see anything that looks like it would let me do this.
Thanks
Edit:
Its ok, ive solved it by doing the following:
Code:
require HTTP::Request;
my $request = HTTP::Request->new( GET => '<url here>' );
my $ua = LWP::UserAgent->new;
my $response = $ua->request( $request );