Re: putting file columns into arrays

2011-05-20 Thread Uri Guttman
> "EM" == Eric Mooshagian writes: EM> I would like a subroutine that will allow me to easily put columns EM> of a tab delimited file into their own arrays. EM> I've been calling the following repeatedly for each column: EM> my @array1 = getcolvals($filehandle, 0); EM> my @array2 =

putting file columns into arrays

2011-05-20 Thread Eric Mooshagian
Dear All, I would like a subroutine that will allow me to easily put columns of a tab delimited file into their own arrays. I've been calling the following repeatedly for each column: my @array1 = getcolvals($filehandle, 0); my @array2 = getcolvals($filehandle, 1); ...etc. sub getcolvals {

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> my $tmp=$fsize-$trunccount; where do those get set? don't name var

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 truncate, it just truncating the size, al

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: 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: $!"; close(fd); print "\nTrunca

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::ReadBackwards->new( $fil

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 want to use truncate, it j

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