truncate

2006-04-23 Thread Smith, Derek
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/) {

truncate word

2004-09-20 Thread mk76
Hi 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. For this I have writ

Re: truncate

2006-04-23 Thread Mr. Shawn H. Corey
> > my $addr=tell(FH); if( $addr < 0 ){ die "tell(FH) failed: $!\n"; } > > #print $addr,"\n"; > > #print $_; > > truncate (FH, $addr); truncate( FH, $addr ) or die "cannot truncate F

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 (/\

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 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

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

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 contain

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

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 w

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

Truncate Last few lines

2011-05-20 Thread Ambuli
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 Remove only Last Two Lines my $bw = File::ReadBack

How to truncate a string?

2001-06-06 Thread Bruno Veldeman
Hi, I have been looking for a function to truncate a string at a given lenght, but am lost. None of the functions seen to do this, I remember BASIC having A$ = left$("1234567890",5). Does perl have this function? What I want is to cut off all strings at a given lenght if the string

Re: Truncate Last few lines

2011-05-20 Thread Shlomi Fish
uot;. > use File::ReadBackwards; Include some empty lines between logical paragraphs of your code. > my $filename = 'test.txt'; This is better specified as a command line argument > my $Lines_to_truncate = 2; # Here the line to truncate is mean Remove > only Last Two Lines The

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

Re: How to truncate a string?

2001-06-06 Thread Eduard Grinvald
rom: "Bruno Veldeman" <[EMAIL PROTECTED]> Date: Wednesday, June 6, 2001 3:15 pm Subject: How to truncate a string? > Hi, > > I have been looking for a function to truncate a string at a given > lenght, but am lost. > > None of the functions seen to do this, I re

Re: How to truncate a string?

2001-06-06 Thread Bruno Veldeman
<[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, June 06, 2001 9:14 PM Subject: Re: How to truncate a string? > substr($word, $start, $end), you could also do a regex, but it'd be at > least twice as slow (i ran benchmarks) > > __END__ > =sincerely, e

Re: How to truncate a string?

2001-06-06 Thread Brett W. McCoy
On Wed, 6 Jun 2001, Bruno Veldeman wrote: > I have been looking for a function to truncate a string at a given lenght, but am >lost. > > None of the functions seen to do this, I remember BASIC having A$ = >left$("1234567890",5). > Does perl have this function? >

RE: How to truncate a string?

2001-06-06 Thread Wagner-David
my $MyPrtVar = $var; if ( length($var) > 8 ) { $MyPrtVar = substr($var,0,8) . '...'; } Wags ;) -Original Message- From: Bruno Veldeman [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 06, 2001 12:16 To: [EMAIL PROTECTED] Subject: How to truncate a string? Hi, I have

Re: How to truncate a string?

2001-06-06 Thread Pete Emerson
Use substr. This will leave you with 5 characters: $text='abcdefghijklmnopqrstuvwxyz'; $text=substr $text, 0, 5; print "$text\n"; Output: abcde Bruno Veldeman wrote: > Hi, > > I have been looking for a function to truncate a string at a given lenght, but am >

Re: How to truncate a string? - correction

2001-06-06 Thread Eduard Grinvald
Bm7LP9rKkMlEqpSJWdS8 > yJmv/9WtDUTZdEJzzFeF+rp2lZpYkI/+sqVJP884fJ9NTS0aXiO1GxQWOKoVE58H > cyrO3hpYgMdC1oP4WZnEJwkLAN+4WnsF2DkKmkNvJRjAANSBTJF3iQBGBBgRAgAG > BQI6+tEnAAoJEDDNAitGCH7xa7AAn0dybVrFf+QHtfgkAsRK3oXY+7gwAJ4sWtYC > GuYw+8LgdC7Mp2ICim9MqA== > =iAF5 > -----END PGP PUBLIC KEY BLOCK- > =cut > &g

Re: RE: How to truncate a string?

2001-06-06 Thread Eduard Grinvald
K- =cut - Original Message - From: Wagner-David <[EMAIL PROTECTED]> Date: Wednesday, June 6, 2001 3:16 pm Subject: RE: How to truncate a string? > my $MyPrtVar = $var; > if ( length($var) > 8 ) { > $MyPrtVar = substr($var,0,8) . '...'; > } > > Wags ;) >

How to truncate few bytes of file

2011-05-20 Thread a b
Hi All, I need to truncate last few bytes of file. these files are big in size. One idea is to write needed bytes to another file and delete the original file, but i am dealing with big files :( dont want to use truncate, it just truncating the size, all data is gone any pointers Thanks a b

Re: How to truncate few bytes of file

2011-05-20 Thread Paul Johnson
On Fri, May 20, 2011 at 03:40:35PM +0530, a b wrote: > Hi All, > > I need to truncate last few bytes of file. these files are big in size. > > One idea is to write needed bytes to another file and delete the original > file, but i am dealing with big files :( > > dont

Re: How to truncate few bytes of file

2011-05-20 Thread a b
Hey Thanks all! I got it ;) open (FH, "+< $fname")|| die "\nFailed to open file $fname\n"; my $tmp=$fsize-$trunccount; seek(FH,$tmp,0); $addr = tell(FH) ; truncate(FH, $addr)|| die "\nFailed to truncate $file: $!";

Re: How to truncate few bytes of file

2011-05-20 Thread Uri Guttman
>>>>> "ab" == a b writes: ab> I need to truncate last few bytes of file. these files are big in size. ab> One idea is to write needed bytes to another file and delete the original ab> file, but i am dealing with big files :( ab> dont want to use

Re: How to truncate few bytes of file

2011-05-20 Thread Uri Guttman
>>>>> "ab" == a b writes: ab> Hey Thanks all! ab> I got it ;) ab> open (FH, "+< $fname")|| die "\nFailed to open file $fname\n"; you don't need to open the file at all. truncate can take a filename. ab>

Re: How to truncate few bytes of file

2011-05-23 Thread a b
ab> Hey Thanks all! > ab> I got it ;) > > ab> open (FH, "+< $fname")|| die "\nFailed to open file $fname\n"; > > you don't need to open the file at all. truncate can take a filename. ab> my $tmp=$fsize-$trunccount; >

How do I truncate or remove a trailing character

2007-08-01 Thread Bret Goodfellow
Okay, I know this has to be simple, but because I am trying to truncate or remove a special character I've run into a roadblock. Here's what I want to do. $value = "12345)" ; How do I change $value so that the trailing ")" is removed. In otherwords wi

RE: How do I truncate or remove a trailing character

2007-08-01 Thread Wagner, David --- Senior Programmer Analyst --- WGO
> -Original Message- > From: Bret Goodfellow [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 01, 2007 14:25 > To: beginners@perl.org > Subject: How do I truncate or remove a trailing character > > Okay, I know this has to be simple, but because I am trying >

Re: How do I truncate or remove a trailing character

2007-08-01 Thread Rob Dixon
Wagner, David --- Senior Programmer Analyst --- WGO wrote: From: Bret Goodfellow [mailto:[EMAIL PROTECTED] Okay, I know this has to be simple, but because I am trying to truncate or remove a special character I've run into a roadblock. Here's what I want to do. $value = "

Re: How do I truncate or remove a trailing character

2007-08-01 Thread John W. Krahn
Bret Goodfellow wrote: Okay, I know this has to be simple, but because I am trying to truncate or remove a special character I've run into a roadblock. Here's what I want to do. $value = "12345)" ; How do I change $value so that the trailing ")" is removed.

Re: How do I truncate or remove a trailing character

2007-08-02 Thread Chas Owens
On 8/1/07, Bret Goodfellow <[EMAIL PROTECTED]> wrote: > Okay, I know this has to be simple, but because I am trying to truncate > or remove a special character I've run into a roadblock. Here's what I > want to do. > > $value = "12345)" ; > > How

Re: How do I truncate or remove a trailing character

2007-08-02 Thread Paul Lalli
On Aug 2, 12:11 pm, [EMAIL PROTECTED] (Chas Owens) wrote: > On 8/1/07, Bret Goodfellow <[EMAIL PROTECTED]> wrote: > > > Okay, I know this has to be simple, but because I am trying to truncate > > or remove a special character I've run into a roadblock. Here's w

Re: How do I truncate or remove a trailing character

2007-08-04 Thread perl pra
Hi Please try the following ___ BEGIN $value = "12345)" ; chop $value; print "$value"; ___ END On 8/2/07, Bret Goodfellow <[EMAIL PROTECTED]> wrote: > > Okay, I know this has to be simple, but because I am trying t

HOW-TO Truncate first line in a file to zero length?

2004-06-22 Thread Amit Kulkarni
Hi, I have small problem. I want to truncate a line in a text file using C file handling functions and write new line in place of it. How do I do it? e.g. "example.txt" Line 1: This is a text file. Line 2: Second line of it. Now I want to truncate first line and replace it wi