Chandu B S wrote:
hi experts
Hello,
I want to delete a line in a file depending on the content of line,
if my file is like this
aaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbb
ccccccc ddddddddd eeeeeee
eeeeee perl ffffffff gggggggg
hhhhhhhhhh
Here i want to remove the 4th line because it contains word "perl" !!
( of course i like perl)
You can do it like this from the command line:
perl -i -pe'$_ = "" if /perl/' /home/file1
i try ed this
open FD , "< /home/file1 " or die " Can't open file1 file : $!";
open FD2 , "> /home/file2 " or die " Can't open file2 file : $!";
while(<FD>)
{
print FD2 $_ unless ($_=~/perl/);
}
close FD;
close FD2;
"and move file2 to file1"
but i don't want to use 2 file ,
can i do this within the original file
To translate the example above to a program:
local ( $^I, @ARGV ) = ( '', '/home/file1' );
while ( <> ) {
$_ = '' if /perl/;
print;
}
close ARGV;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>