Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks!
I am trying to read some file(s), get its size, and if the file(s) are larger than what I've declared in the variable $last_maxsize, delete over sized file content until it reaches the size specified. For some reason the code is deleting all the lines in the file(s) but the first line, the number in the $last_maxsize variable is just been ignored, can anyone help me on that?
Here is the piece of code doing that:
Thanks a lot!
I am trying to read some file(s), get its size, and if the file(s) are larger than what I've declared in the variable $last_maxsize, delete over sized file content until it reaches the size specified. For some reason the code is deleting all the lines in the file(s) but the first line, the number in the $last_maxsize variable is just been ignored, can anyone help me on that?
Here is the piece of code doing that:
my $last_maxsize = 170000; #I need to delete original files here... open my $last_in, '<', "$path_only/$file_name" or die $!; { local $/ = \$last_maxsize; while ( my $new_record = <$last_in> ) { next if -s $new_record > $last_maxsize; open my $last_out, '>', "$path_only/$file_name" or die $ +!; #It should create the file(s) with a new size print $last_out $new_record; close $last_out or die $!; } close $last_in; }
Thanks a lot!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Delete On File Size
by Fletch (Bishop) on Feb 17, 2006 at 15:55 UTC | |
Re: Delete On File Size
by mikeock (Hermit) on Feb 17, 2006 at 15:50 UTC | |
by Anonymous Monk on Feb 17, 2006 at 15:56 UTC | |
by mikeock (Hermit) on Feb 17, 2006 at 16:20 UTC | |
Re: Delete On File Size
by wulvrine (Friar) on Feb 17, 2006 at 17:20 UTC | |
Re: Delete On File Size
by graff (Chancellor) on Feb 18, 2006 at 16:09 UTC |
Back to
Seekers of Perl Wisdom