Sara wrote:

> I have an input coming from scrolling textbox eg.
>  
> $description = qq~
> This is my description. Here goes a couple of headings in it
> Heading abc:
> this is the heading one and needs to bold and underlined
> Heading xyz:
> needs to bold and underlined too.
> description continues here
> ~;
>  
> I am producing HTML files from input. I need to underline and make bold
> these headings when the output is
> generated. Any ideas on how to extract these headings and make the
> changes for output?
>  
> The two definate markers for these headings are there is always a line
> break before and after the heading and it always contains the colon at
> the end :

Try something like (make sure you decode any %XX escapes in the data first):

use strict;

my $description = qq~
This is my description. Here goes a couple of headings in it
Heading abc:
this is the heading one and needs to bold and underlined
Heading xyz:
needs to bold and underlined too.
description continues here
~;

foreach (split "\n", $description) {

        if (/^heading\s+(.*)\s*:/i) {
                print "<H1>$1</H1>\n";
        } else {
                print "$_\n";
        }
}

__END__



-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (Free site for Perl/Lakers)

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to