Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
This content can sometimes be found on multiple lines. I am able to grab the content that is found on only one line by the following code<meta http-equiv="Keywords" content="Sun, Sun Bank, Bank, banking>
I am having trouble when I need to grab the content from multiple lines the code I am using to try and do this is#if the meta is only on one line if (/\<meta(.*)\>/i) { # grab the meta tag lines print OUTFILE $_ . "\n"; }
#grabbing and printing everything between the meta tags if it +is on multiple lines if (/<meta.*?>/i ... /.*?>/i){ # this is a title line # extract the title $meta_temp = $_; $meta_temp =~ s/(.*?)\<meta\>(.*?)\>/$2/i; chomp($meta_temp); $meta = "$meta_temp" ; # Write the meta to the output file print OUTFILE $meta . "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: grabbing and printing text
by merlyn (Sage) on May 09, 2001 at 19:31 UTC | |
by Anonymous Monk on May 09, 2001 at 19:36 UTC | |
by merlyn (Sage) on May 09, 2001 at 19:37 UTC | |
by ChemBoy (Priest) on May 09, 2001 at 20:12 UTC |