-----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(/usr/local/admin/perl/derek_perl/test);
>
> open (FH, "+< $file");
>
> while ( <FH> ) {
>
> if (/\Acheck\-names/) {
>
> 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 FH: $!\n";
>
>
>
> }
>
> }
--
__END__
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
******************************************************************
This does not work as my file still contains both lines.
check-names warn;
fooy
when I want it to only contain
fooy
use strict;
use warnings;
my $file = qq(/usr/local/admin/perl/derek_perl/test);
open (FH, "+< $file") or warn $!;
foreach ( <FH> ) {
if (/\Acheck\-names/) {
my $addr=tell(FH);
if ($addr < 0) {
die "tell(FH) failed: $!\n";
}
truncate (FH,$addr) or die "cannot truncate FH: $!\n";
}
}
close (FH) or warn $!;
Cardinal Health -- Working together. For life. (sm)
_________________________________________________
This message is for the designated recipient only and may contain privileged,
proprietary, or otherwise private information. If you have received it in
error, please notify the sender immediately and delete the original. Any other
use of the email by you is prohibited.
Dansk - Deutsch - Espanol - Francais - Italiano - Japanese - Nederlands - Norsk
- Portuguese - Svenska: www.cardinalhealth.com/legal/email
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>