http://www.perlmonks.org?node_id=886409


in reply to Simple Text Manipulation

I canít use a simple search and replace because the Article numbers change. Can Perl be used to do this?

Well fortunately Perl doesn't restrict you to simple search and replace, instead you have arguably the most powerful regular expression engine in the known universe! Perlre's eat changing numbers for breakfast whilst blindfolded with all eight limbs tied behind their backs. Some suggestions to add to Corion's sage advice:

As a trivial solution I offer this simple modification of JavaFan's solution which you would apply line by line as you read through the file, but note it will not work if you have a different specification for the lines. I prefer to be as specific as I can in regular expressions, so know your data.

s/^(Article\s+[0-9]+\s+[\w\s]+$)/\\subsection*{$1}/;

--
I'd like to be able to assign to an luser