Re: Truncate Last few lines

2011-05-20 Thread C.DeRykus
On May 20, 4:37 am, cmksw...@gmail.com (Ambuli) wrote: > Here i paste a perl script to delete last Two Lines. If you want > delete more lines in a file you can specify it. > > use File::ReadBackwards; >  my $filename = 'test.txt'; >  my $Lines_to_truncate = 2; # Here the line to truncate is mean Re

Re: Truncate Last few lines

2011-05-20 Thread Shlomi Fish
Hi Ambuli, a few comments on your code: On Friday 20 May 2011 14:37:52 Ambuli wrote: > Here i paste a perl script to delete last Two Lines. If you want > delete more lines in a file you can specify it. > > Always start with "use strict;" and "use warnings". > use File::ReadBackwards; Include

Re: truncate

2006-04-25 Thread Tom Allison
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 As others have said, this will lop off the end of the file. Another option is to run perl -i and edit the file in place. while(<>){ print if /Acheck\-names/ } But under

RE: truncate

2006-04-23 Thread Mr. Shawn H. Corey
On Sun, 2006-23-04 at 17:07 -0400, Smith, Derek wrote: > This does not work as my file still contains both lines. > check-names warn; > fooy > > when I want it to only contain > fooy That's not what truncate does. It chops off the end of the file. What you have to do is copy the contents to a tem

RE: truncate

2006-04-23 Thread Smith, Derek
-Original Message- From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] Sent: Sunday, April 23, 2006 1:51 PM To: Perl Beginners Subject: Re: truncate On Sun, 2006-23-04 at 13:29 -0400, Smith, Derek wrote: > use strict; > > use warnings; > > > > my $file = qq(

Re: truncate

2006-04-23 Thread John Ackley
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 ( ) { unless (/\Acheck\-names/) {

Re: truncate

2006-04-23 Thread Mr. Shawn H. Corey
On Sun, 2006-23-04 at 13:29 -0400, Smith, Derek wrote: > use strict; > > use warnings; > > > > my $file = qq(/usr/local/admin/perl/derek_perl/test); > > open (FH, "+< $file"); > >while ( ) { > > if (/\Acheck\-names/) { > > my $addr=tell(FH); if( $addr < 0

Re: truncate word

2004-09-20 Thread John W. Krahn
Gunnar Hjalmarsson wrote: John W. Krahn wrote: [EMAIL PROTECTED] wrote: I have a file which contains a number of instances of the word "FINAL". I need to truncate all the instances of this word and create an output string of the rest of the words in the same line in the file. Rest all lines not con

Re: truncate word

2004-09-20 Thread Gunnar Hjalmarsson
John W. Krahn wrote: [EMAIL PROTECTED] wrote: I have a file which contains a number of instances of the word "FINAL". I need to truncate all the instances of this word and create an output string of the rest of the words in the same line in the file. Rest all lines not containing the word are to be

Re: truncate word

2004-09-20 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi Hello, I have a file which contains a number of instances of the word "FINAL". I need to truncate all the instances of this word and create an output string of the rest of the words in the same line in the file. Rest all lines not containing the word are to be ignored. F

Re: truncate word

2004-09-20 Thread Jeff 'japhy' Pinyan
On Sep 20, [EMAIL PROTECTED] said: >I have a file which contains a number of instances of the word "FINAL". >I need to truncate all the instances of this word and create an output >string of the rest of the words in the same line in the file. Rest all >lines not containing the word are to be ignor