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

louhevly

by louhevly (Novice)
on Jan 08, 2017 at 08:16 UTC ( [id://1179158]=user: print w/replies, xml ) Need Help??

I'm an American teacher of English living in a small city 40 miles northwest of Barcelona. My website visca.com, mostly in Catalan, uses Perl and CGI.pm for a host of interactive pages. I've been using Perl since the Matt Wright days (How was a poor newbie to know?) and learned it mostly from comp.lang.perl.misc and the Camel book. Besides using Perl for interactive pages, I find it to be very useful munging text files. Since this textarea is quite large, I suppose I'm encouraged to give an example of how Perl makes life easier for me:

I have 350 lines of text like this:

9) burst into [suddenly enter] — entrar d'un cop a. ex.: He burst into + the room. 10) call for — 1 [demand] exigir. ex.: He called for an end of the war +. 2 [pick up] anar a recollir. ex.: I'll call for you at six. 3 [be t +he occasion for] ser ocasió de. ex.: This calls for an investigation +/ for a celebration.
I want them to be like this:
9) <b>burst into</b> [suddenly enter] — entrar d'un cop a. ex.: <b>He +burst into the room.</b><br> 10) <b>call for</b> — 1 [demand] exigir. ex.: <b>He called for an end +of the war.</b> 2 [pick up] anar a recollir. ex.: <b>I'll call for yo +u at six.</b> 3 [be the occasion for] ser ocasió de. ex.: <b>This cal +ls for an investigation / for a celebration.</b><br>
This is the heart of what I came up with:
while (<F>) { chomp; if (m~ 1 ~) { s~\) (.+) \—~) <b>$1</b> —~g; } else { s~\) (.+) \[~) <b>$1</b> [~; } s~(exs?)\.: (.+?)\.~$1.: <b>$2</b>.~g; s~([A-Z].+?(\.|\?|\!))~<b>$1</b>~g; print G "$_<br>\n"; }
If it weren't for perl I wouldn't have a clue how to do this except by hand. 350 lines!!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-18 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found