On Wed, 2004-05-19 at 15:52, Graf Laszlo wrote:
> Hi
Hi
> I have the following HTML structure:
>
> <sm:a>
> <sm:b>
> BBB
> </sm:b>
> <sm:c>
> CCC
> </sm:c>
> </sm:a>
>
> Every line in this structure is an element of an array,
> named @lines, and I access the elements using a foreach loop.
>
> When I know the tag's name, by example 'sm:a',
> and I need to extract the information contained by '<sm:a>'
> and '</sm:a>' pair and the tags too, how should I proceed ?
> I tried a regexp like this:
>
> foreach $s (@lines) {
> print "$s";
> if($s =~ m|^(<sm:a>\\n)(.*?)(\\n<\/sm:a>)$|s){
> ($l,$c,$r) = ($1,$2,$3);
> print "OK\n";
> print "l: '$l'\n";
> print "c: '$c'\n";
> print "r: '$r'\n";
> }else{
> print "HEHE\n";
> }
> }
The problem is that your expression is supposed to be applied to the
whole text, but you're applying it to each line at a time.
Try this:
for (@lines) {
if ( /<sm:a>/ .. /<\/sm:a>/ )
{
print
}
}
> Help me. Thank you.
HTH,
jac
--
Josà Alves de Castro <[EMAIL PROTECTED]>
Telbit - Tecnologias de InformaÃÃo
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>