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
In reply to Re: Writing to DATA
by Anonymous Monk
in thread Writing to DATA
by sweetblood
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |