Shameless plug: You might be interested in my module Data::Undump::PPI. It uses a static parse so it's safer than eval.
I dumped a hash into a file and then copied into the __DATA__section of my script.
Although I wouldn't recommend this for real-world use (use a config file instead), see my reply in the thread Is it possible to modify __DATA__ via the DATA file handle or otherwise? for a script that modifies its own __DATA__ section:
use warnings;
use strict;
use File::Replace 'replace3';
use Data::Undump::PPI qw/Dump Undump/;
my $pos = tell DATA;
my $data = Undump(fh => *DATA);
$data->{counter}++;
my (undef,$outfh,$repl) = replace3(__FILE__,':raw');
$repl->copy($pos);
Dump([$data], fh=>$outfh);
$repl->finish;
__DATA__
$VAR1 = {
counter => 0
};