in reply to Writing to DATA
The DATA filehandle is just a an open handle on the current file. The current file is just the $0 variable (so long as you haven't changed it). So:
# main part of script ... # then redo the crc: rewrite_crc('datafile'); sub rewrite_crc { my $file = shift; open(SELF,"+<$0")||die $!; while(<SELF>){last if /^__END__/} print SELF new_crc($file),$/; truncate(SELF,tell SELF); close SELF; } sub new_crc { my $file = shift; my $crc = 0; # calculate new crc here $crc = 43256; return $crc; } __END__ 1234567
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Writing to DATA
by bart (Canon) on Nov 15, 2003 at 07:31 UTC | |
|
Re: Re: Writing to DATA
by sweetblood (Prior) on Nov 14, 2003 at 17:30 UTC | |
by Anonymous Monk on Nov 14, 2003 at 17:43 UTC | |
by sweetblood (Prior) on Nov 14, 2003 at 18:23 UTC | |
by Anonymous Monk on Nov 14, 2003 at 18:40 UTC |