1URI::Title(3) User Contributed Perl Documentation URI::Title(3)
2
3
4
6 URI::Title - get the titles of things on the web in a sensible way
7
9 version 1.904
10
12 use URI::Title qw( title );
13 my $title = title('http://microsoft.com');
14 print "Title is $title\n";
15
17 I keep having to find the title of things on the web. This seems like a
18 really simple request, just get() the object, parse for a title tag,
19 you're done. Ha, I wish. There are several problems with this approach:
20
21 What if the resource is on a very slow server? Do we wait for ever or
22 what?
23 What if the resource is a 900 gig file? You don't want to download
24 that.
25 What if the page title isn't in a title tag, but is buried in the HTML
26 somewhere?
27 What if the resource is an MP3 file, or a word document or something?
28 ...
29
30 So, let's solve these issues once.
31
33 only one, the title(url) method. Call it with an url, get the title if
34 possible, undef if it wasn't. Very simple.
35
37 WWW::GetPageTitle - similar this module, but just handles web pages.
38 The author of that module suggests you should use "URI::Title".
39
41 Embedded title metadata of png files can be extracted if you have
42 installed either Image::ExifTool or Image::PNG::Libpng.
43
45 Many, many, many things. Still unimplemented:
46
47 Get titles of MP3 files, Word Docs, PDFs, etc.
48 Configurable.. well, anything, in fact. Timeout would be a good start.
49 Better error reporting.
50
52 Tom Insam <tom@jerakeen.org>, original author, 2004-2012.
53
54 Philippe Bruhat (BooK) <book@cpan.org>, maintainer, 2014.
55
57 This software is copyright (c) 2004 Tom Insam.
58
59 This program is free software; you can redistribute it and/or modify it
60 under the same terms as Perl itself.
61
63 Invented because of a conversation with rjp, who contributed some
64 eyeball-melting and as-yet-unused code to get titles from MP3s and
65 PDFs, and hex, who has also solved the problem, and got bits done in a
66 nicer way than I did.
67
68
69
70perl v5.38.0 2023-07-21 URI::Title(3)