Smith, Derek wrote:
I want to use truncate to delete a matched line out a named.conf file on
my DNS box.
Here is my code
use strict;
use warnings;
my $file = qq(/usr/local/admin/perl/derek_perl/test);
open (FH, "+< $file");
while ( <FH> ) {
unless (/\Acheck\-names/) {
print $_;
}
}
The above code works as expected: perl myfile > foo
but can I use truncate as below:
use strict;
use warnings;
my $file = qq(/usr/local/admin/perl/derek_perl/test);
open (FH, "+< $file");
while ( <FH> ) {
if (/\Acheck\-names/) {
my $addr=tell(FH);
#print $addr,"\n";
#print $_;
truncate (FH, $addr);
}
}
The test files contains:
check-names warn;
fooy;
I want to remove only the "check-names warn" line but the above code
removes all lines???
Any help? Thank you
perldoc -f truncate
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>