Jeff and John, thanks for your help. I'm invoking my script with a command line loop:
perl -n pop2html.pl 2001-07-16.txt

The file pop2html.pl, incorporating your suggestion, is:
if (! /[a-z]/) {chomp; print "<h4>$_</h4>\n"; next;}
if (/^\s*$/) { print "<br>\n"; next;}

The tail of the file 2001-07-16.txt is:
WOMEN'S HEALTH

Endometriosis: A Clinical Review
http://www.bmj.com/cgi/content/full/323/7304/93 


YOUTH

Renewed Hope for the World's Children
http://www.earthtimes.org/jul/childrenrenewedhopejul12_01.htm 


The output of the program is:
<h4>WOMEN'S HEALTH</h4>
<h4></h4>
<h4></h4>
<h4></h4>
<h4>YOUTH</h4>
<h4></h4>
<h4></h4>
<h4></h4>

As you can see, the first line in pop2html.pl is matching everything, and the second 
line is never executing. I think that this is because the first line matches on any 
character that is not a lower-case, including spaces and the occasional capital in an 
abbreviation or first word of a sentence.

Thanks, again, for your help. Any other suggestions?

-Kevin


>>> [EMAIL PROTECTED] 07/23/01 10:00AM >>>
On Jul 23, KEVIN ZEMBOWER said:

>I need help writing a regular expression that will match lines that have
>only upper case letters, and sometimes slashes and spaces, but won't
>match lines with mixed case.
>
>Lines that must be matched are like:
>FAMILY PLANNING / REPRODUCTIVE HEALTH POLICY
>FAMILY PLANNING / REPRODUCTIVE HEALTH PROJECTS
>PUBLIC HEALTH
>HIV/AIDS

You should probably just use a regex like:

  if ($line !~ /[a-z]/) {
    # it's ok
  }

That regex says "if $line does NOT contain a lower-case letter, let it
pass."

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/ 
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/ 
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/ 
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to