SPUG: Matching HTML Meta Tags

Parr, Ryan Ryan.Parr at wwireless.com
Sun Jul 22 16:31:22 CDT 2001


I'm sure I'm missing something very easy, but any help would be appreciated
in this matter.

I'm trying to document the html files of my site with meta tags
(name="keywords",name="description"). Unfortunately I don't seem to be able
to pull out the content portion of the meta tag.

For example

$file = <<EOF;
<html>
<head>
<title>Untitled Page</title>
<meta name="keywords" content="Just, A, Comma, Seperated, List">
<meta name="description" content="Just a plain old description">
...lots of html here...
EOF

Now, if I run the following pattern match:
$file =~ m/<meta\s+name\s*=\s*"description"\s+content\s*=\s*"(.*)?"\s*>/sig;
It matches everything up to the last double quote in the file content, as
though I had left out the non-greedy quantifier.

However, $file =~ m/<title>\s*(.*)?\s*<\/title>/sig; properly matches just
the title. 

Like I said, I'm sure I'm missing something easy, but I'm definately missing
it completely. Any ideas?

-- Ryan Parr

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list