Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Perl & Groff (psed)

by blue.monk (Novice)
on Jun 23, 2004 at 15:52 UTC ( #369087=perlquestion: print w/ replies, xml ) Need Help??
blue.monk has asked for the wisdom of the Perl Monks concerning the following question:

Howdy --

groff (-mm) takes:

THE QUICK BROWN FOX
jumped over the lazy dog
And turns it into this:
THE QUICK BROWN FOX jumped over the lazy dog
What I want use psed to turn it into this:
.H 
THE QUICK BROWN FOX
.BP
jumped over the lazy dog
In short anytime there's 2 or more CAPS work togather insert a .H (header) tag beofore and a .BP (paragraph break at the end of the CAP words.

Any ideas?
David

 editted by jeffa - formatting 

Comment on Perl & Groff (psed)
Re: Perl & Groff (psed)
by gellyfish (Monsignor) on Jun 23, 2004 at 16:12 UTC

    You mean something like:

    perl -pi -e's/(^.*[A-Z]{2,}.*)$/.H\n$1\n.BP/' <files>
    ?

    /J\

Re: Perl & Groff (psed)
by Abigail-II (Bishop) on Jun 23, 2004 at 16:15 UTC
    You mean something like this:
    s/([A-Z][A-Z\s]*[A-Z])\s*/.H\n$1\n.BP\n/g

    Abigail

Re: Perl & Groff (psed)
by blue.monk (Novice) on Jun 23, 2004 at 23:30 UTC
    Thanks to you both :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://369087]
Approved by jlk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2015-07-03 00:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls