🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #13284

Re: Sustituir una sola vez con sed (o perl)

#13284
From: Han Solo
Date: Thu, 08 Mar 2001 00:52
58 lines
2723 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Han Solo <hsolo@escomposlinux.org> writes:

> Tambi�n lo he intentado con perl, pero lo sustituye para cada p�gina
> (la opci�n del perl, no le he probado mucho, pero no quiero tener un
> "programa", preferir�a que fuera un simple flitro de comando).

Pues al final, me lo he hecho con perl, que es lo que tendr�a que
haber hecho desde el principio, y dejarme de exotismos. Os pego el
filtro que me he construido, por si a alguien le interesa o lo quiere
mejorar:

- -------addpag------------
#!/usr/bin/perl
# Addpag  08/03/01
# A�ade una p�gina en blanco a un fichero postscript
# �til cuando se imprimen dos p�ginas por cara (con psnup, por ejemplo)
# para que queden las p�ginas en su sitio.

# Se usa como un filtro: addpag fichero.ps o bien cat fichero.ps|addpag

$cadena = "%----------------\n%%Page: 0 0\nshowpage\n%----------------\n%%Page:";
$num = 0;
while (<>) {
    $lin = $_;
    if ( /(\%\%Page:)/ and $num <1 ){
	s/$1/$cadena/;
	++$num;}
    print $_;
}
- -------addpag------------

> Por cierto, la p�gina man de sed sux :-)

Rectifico: todo el sed es infernal.

- -- 
Un Saludo

Han Solo
The Rebel Alliance

Emacs is not on every system

So what? [...] Do you tell your administrative people to stick with
notepad.exe? Do you tell your fat kids they can only have the crummy
games that come with their video games or plain dress that comes with
Barbie?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.5 and Gnu Privacy Guard <http://www.gnupg.org/>

iEYEARECAAYFAjqm17QACgkQ4FjpJaPEp23logCfTEt0kGqlUh95SgJDRxwXTOan
U9QAoJ6KihbHqZHQjjizvgsetcd4+JC0
=cfNJ
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <87g0gp6q14.fsf@alderaan.maptel.es>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!nntp.cs.ubc.ca!fu-berlin.de!uni-berlin.de!212-7-51-145.wolbiz.worldonline.ES!not-for-mail
References: <8766hn6jpk.fsf@alderaan.maptel.es>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,57bf867c8699b7fc
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-03-07 19:04:07 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!nntp.cs.ubc.ca!fu-berlin.de!uni-berlin.de!212-7-51-145.wolbiz.worldonline.ES!not-for-mail
From: Han Solo <hsolo@escomposlinux.org>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Sustituir una sola vez con sed (o perl)
Date: 08 Mar 2001 01:52:07 +0100
Organization: The Rebel Alliance
Lines: 58
Message-ID: <87g0gp6q14.fsf@alderaan.maptel.es>
References: <8766hn6jpk.fsf@alderaan.maptel.es>
NNTP-Posting-Host: 212-7-51-145.wolbiz.worldonline.es (212.7.51.145)
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: fu-berlin.de 984020486 663707 212.7.51.145 (16 [63837])
X-Server-Date: 8 Mar 2001 00:52:07 GMT
User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7