use Data::Dump::Streamer; ## Calling this sub sub callersCode{ my $d=Data::Dump::Streamer->new; my @i=caller(1); $d->Deparse(1); return scalar $d->Dump( *{$i[3]} )->Out(); };; ## from this one sub fred { my( @x ) = @_; for ( @x ) { m[a] and s[a][A]g; } print callersCode(); };; ## When called fred( 1,2,3 );; ## this output is produced $VAR1 = *::fred; *::fred = sub { BEGIN { $^H{'feature_say'} = q(1); $^H{'feature_state'} = q(1); $^H{'feature_switch'} = q(1); } my(@x) = @_; foreach $_ (@x) { s/a/A/g if /a/; } print callersCode(); };