Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

I am using WWW::Mechanize module to extract hyperlinks and download a file from website

I have a small problem to identify the file name of the current page

$temp="https://www.ctslink.com/a/document.html?key=2988562"; $mech->get($temp); $mech->save_content();

The above mentioned url is a pdf file link and url has only key value there is no extension or file name, my question is how do i extract the pdf file name? even i used $mech->title() to get title but it seems a null string only

Any Idea...

Replies are listed 'Best First'.
Re: To find the Title of current page
by Corion (Patriarch) on May 23, 2016 at 08:54 UTC

    If the page sends a real filename, it will be in the Content-Disposition header of the response.

    Otherwise, there is no way to get at the title of a PDF file from within WWW::Mechanize. You will need one of the PDF modules to extract the metadata from a PDF file.

      Yeah Thanks it's work fine