in reply to Re^3: How to get code of the calling function or object
in thread How to get code of the calling function or object

I started doing something like this after I came across a node a while back. I cannot find the link to the node now.

My test code was

use B::Deparse; my $sr = sub { print "Hello\n" }; $sr->(); my $code = B::Deparse->new->coderef2text($sr); $code =~ s/print \s\S+/die "Bye";/; $sr = eval "sub $code"; $sr->();