Dear zavierz
probably you can try this
$I=~s/^(Article\s+[0-9]+\s+[\A-Z_a-z]+\S)/\\subsection*{$1}/g;
print "$I";

--- On Sat, 5/2/11, zavierz <[email protected]> wrote:

From: zavierz <[email protected]>
Subject: Text Manipulation
To: [email protected]
Date: Saturday, 5 February, 2011, 8:41 PM

Hi, I am trying to modify a LaTex file which is plain text.
The file contains lines similar to the following, but each line is
followed by text, so that:

Article 1  Cats
Article 2  Dogs
Article 3  Fish
Article 4  Ferrets

etc.

I would like to modify the file so that each referenced line is
changed as follows:

\subsection*{Article 1 Cats}
\subsection*{Article 2 Dogs}
\subsection*{Article 3 Fish}
\subsection*{Article 4 Ferrets}

Here's code which was suggested to me, but when I execute it I'm
returned to the command line and nothing happens:

#!/usr/bin/perl
s/^(Article\s+[0-9]+\s+\N*\S)/\\subsection*{$1}/gm

I called this script "Article" and saved it as article.pl
The usage then was $perl article.pl oldfile.tex newfile.tex

and I got the following error message:

Missing braces on \N{} at article.pl line 2, within pattern
Nested quantifiers in regex; marked by <-- HERE in m/^(Article\s+[0-9]+
\s+* <-- HERE \S)/ at article.pl line 2.

So I added braces as follows:  \{N}

I ran the script again; there was no error message but no newfile.tex
either.
I then ran the program as follows:

$perl article.pl oldfile

And the response is the command prompt and the file hasn't been
modified.

any suggestions?


-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/




Reply via email to