[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Need better way to skin a cat



Shawn suggests:
> At 7:18 PM 5/20/96, Eric Muehling wrote:
> >Is a way to get Perl to match <*> (the symbols
> >and everything between) and delete? I prefer a
> >wildcard searh because there are many, many
> ><styletags> to deal with. I don't want to require
> >exact name matches, just <wildcardtag> matches.
> 
> How bout:
> 
> #!perl
> 
> open (IN, $in);
> open (OUT, ">$out");
> select (OUT);
> while (<IN>) {
>         s/<[^>]*>//g;

Alternatively, if you use MacPerl 5 (or Perl 5 in general), this line
could be:
        s/<.*?>//g;

This is called "nongreedy" patternmatching, and may or may not be easier
to read in your code.  (It's most useful when the "brackets" are
multiple characters.)  Read the "perlre" manpage.

> Shawn.

Don

-=-=-=-Don Blaheta-=-=-=-blahedo@quincy.edu-=-=-=-dblaheta@aol.com-=-=-=-

First Law of Socio-Genetics:
        Celibacy is not hereditary.