#! /usr/bin/perl # Write-Read-Execute code # my %hash = (); $hash{code} = sub { print "Hi Guy - Hello Fellow!\n" }; &{$hash{code}}(); print $hash{code},"\n"; my $string = str_Code($hash{code}); $hash{code} = code_String( split(/\n/, $string) ); # this should work (as before saved): print $hash{code},"\n"; &{$hash{code}}(); # the two subs sub str_Code { use B::Deparse; return B::Deparse->new("-p", "-sC")->coderef2text( shift )."\n"; } sub code_String { my $ret; while ( @_ ) { $ret .= (shift)."\n"; # "\n" was eliminated by split } # NOW MAKE $ret been executed: # This is the examlpe of B:Deparse: #eval "sub func $ret"; # but nothing happens # this causes this mistake: # Undefined subroutine &sub #&{$ret}; # this should be given back: return \&{$ret}; }