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 };