Reply to question below...
Use \@ to escape a @. Otherwise @ will be interpreted by Perl as the
start of a name of an array.
In a similar manner, use \\ to escape a \.
Your example code uses \\\\ where \\ is needed.
Here is the revised code (which works on Perl 5.14 on Debian Linux):
perl -pi -e 's/\\begin{document}/\\makeatletter\n\\AtEndDocument{\\if
\@longauth\\\@longauthfalse\\fi}\n\\makeatother\n\n\\begin{document}/g'
test.tex
With the -i switch, you are editing file test.tex. When debugging, you
might want to omit the -i switch. The changed text will be written to
STDOUT instead of the file. That will make tweaking the code and
re-testing easier.
On Wed, 2014-07-23 at 13:07 +0000, Mohamed HOUSSNI wrote:
> Dear list,
>
> Is that someone could take a look at this problem ?
>
> Thanks a lot,
>
> MHTML Document attachment (help)
> > -------- Forwarded Message --------
> > From: Mohamed HOUSSNI <[email protected]>
> > To: [email protected]
> > Subject: help
> > Date: Tue, 22 Jul 2014 12:00:31 +0000
> > From: Mohamed HOUSSNI <[email protected]>
> > User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716)
> > To: [email protected]
> > Subject: help
> >
> > Dear list,
> >
> > I am writing to you about a problem "perl -pi". I'm trying to
replace a
> > string by another which contains the caracter array declaration "@"
> > ie
> > substitute "blabla" with "\if@longtable" but I can not do it via > >
> > "perl
> > -pi -e". Below my command line
> > perl -pi -e
> > 's/\\\\begin{document}/\\\\makeatletter\n\\\\AtEndDocument{\\\\if
\@longauth\\\\\@longauthfalse\\\\fi}\n\\\\makeatother\n\n\\\
\begin{document}/g'
test.tex
> > To insert in "test.tex"
> > \makeatletter
> > \AtEndDocument{\if@longauth\@longauthfalse\fi}
> > \makeatother
> > Thank you in advance for your help.
> > --
> > -------------------
> > Dr. Mohamed Houssni
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/