Regex find and replace - delete line
- From: james@xxxxxxxxxxxxxxxxx (James Turnbull)
- Date: Sun, 23 Jul 2006 16:01:17 +1000
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160
Hi all
This feels like a really dumb question but doing a regex find and
replace is it possible to delete a line? For example,
for (@file) {
s/foo//g;
}
which equates to:
for each element in array 'file' if you find 'foo' then replace it with
null.
I then write the array to a file (using Tie::File) and it leaves a blank
line where the element containing 'foo' was like:
null
foo1
foo2
foo3
Perhaps I am confabulating two ideas here? Is there a way to walk
through an array and find a particular array element and delete it
rather than replace it with null (and then write it out to a file using
Tie::File)?
Thanks
James Turnbull
- --
James Turnbull <james@xxxxxxxxxxxxxxxxx>
- ---
Author of Pro Nagios 2.0
(http://www.amazon.com/gp/product/1590596099/)
Hardening Linux
(http://www.amazon.com/gp/product/1590594444/)
- ---
PGP Key (http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x0C42DF40)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)
iD8DBQFEwxCt9hTGvAxC30ARA3AUAKDQeVzurdxg3GMnwVlokIwk48Ed+ACghe0X
BJ+hUGw/QYUtQCSKU6+J8uk=
=Dmhk
-----END PGP SIGNATURE-----
.
- Follow-Ups:
- Re: Regex find and replace - delete line
- From: John W. Krahn
- Re: Regex find and replace - delete line
- From: D. Bolliger
- Re: Regex find and replace - delete line
- Prev by Date: RE: fork question
- Next by Date: parseform.lib
- Previous by thread: fork question
- Next by thread: Re: Regex find and replace - delete line
- Index(es):
Relevant Pages
|