[oclug]Really basic Perl help

Milan Budimirovic milan.budimirovic at sympatico.ca
Mon Jan 6 20:25:28 EST 2003


On Mon, 2003-01-06 at 16:24, Ahmed Masud wrote:
> B McKee wrote:
> 
> >In truth I want to be able to read in an HTML file and output a subsection 
> >that is framed with a specific <--! Comment -->  
> >I gather their may be a module that would help, but I thought my needs could 
> >be handled by a simple regular expression search.  Since this will end up on 
> >someone else's server I didn't want to have to install any extra software to 
> >make it work.
> >
> >  
> >
> <sigh> why make things Sooooooooooo complicated!
> 
> #!/usr/bin/perl
> $flag = 0;
> while (<>) {
>     /<!-- comment -->/ && do { $flag = !$flag; next; } ;
>     print if ( $flag );
> }
> 
> A
> 

Again, it's simple if the comment is always going to appear on a single
line. But what if it's

<!-- this could be a very long comment spread out
over two or more lines -->





More information about the OCLUG mailing list