Based on your response I conclude that this snippet is inside a while loop. I also conclude that the <title> and <meta> tags are on seperate lines.
use strict; my ($title,$meta) = ('',''); while (<DATA>) { ## <DATA> for test chomp; # .. if (/<title>/i) { $title = $_; $title =~ s/<title>(.+?)<\/title>/$1/i; } if (/<meta/i) { $meta = $_; $meta =~ s/<meta .+? CONTENT="(.+?)">/$1/i; } #.. } print "RESULT:\n$title\n$meta\n"; __DATA__ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/T +R/html4/strict.dtd"> <html><head> <TITLE>untitled</TITLE> <META NAME="description" CONTENT="An introduction to the basics of Per +l scripting."> </head> <body> </body> </html>
In reply to Re^3: Meta tag
by nedals
in thread Meta tag
by No-Lifer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |