|
Posted by Gunnar Hjalmarsson on March 17, 2008, 6:18 pm
Please log in for more thread options Koszalek Opalek wrote:
> On Mar 17, 12:32 pm, INVALID_SEE_...@example.com.invalid (J.D.
> Baldwin) wrote:
>> Simple problem. Given a URLhttp://www.example.com/some/file/here.html,
>> retrieve and extract the title of the web page -- i.e., the content
>> of the <title> tag. Is there an equally simple solution? Thanks in
>> advance for any advice.
>
> #!/usr/bin/perl
>
> use strict;
> use LWP::Simple;
>
> my $url = $ARGV[0] || die "Specify URL on the cmd line";
> my $html = get ($url);
> $html =~ mgism;
>
> print "$1\n";
Why the /g and /m modifiers?
What if the <title> element contains attributes?
Improved (I hope) code:
$html =~ mis;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
|