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;
>
>>>>> "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>
>>>>> "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
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
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
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: $!";
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
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
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
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
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
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
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.
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 = "
> -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
>
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
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
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
-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(
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 (/\
>
> 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
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/) {
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
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
[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
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
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
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
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 ;)
>
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
>
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
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?
>
Bm7LP9rKkMlEqpSJWdS8
> yJmv/9WtDUTZdEJzzFeF+rp2lZpYkI/+sqVJP884fJ9NTS0aXiO1GxQWOKoVE58H
> cyrO3hpYgMdC1oP4WZnEJwkLAN+4WnsF2DkKmkNvJRjAANSBTJF3iQBGBBgRAgAG
> BQI6+tEnAAoJEDDNAitGCH7xa7AAn0dybVrFf+QHtfgkAsRK3oXY+7gwAJ4sWtYC
> GuYw+8LgdC7Mp2ICim9MqA==
> =iAF5
> -----END PGP PUBLIC KEY BLOCK-
> =cut
>
&g
<[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
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
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
36 matches
Mail list logo