#! /usr/bin/perl # write-read-execute code my %hash = (); # btw, all of a sudden there is a syntax error near: $hash{ # I have no idea why (can't test this, while simular code works?) $hash{'code'} = sub { print "Hi Guy - Hello Fellow!\n" }; &$hash{'code'}(); my $string = toStr($hash{'code'}; $hash{'code'} = toCode( split(/\n/, $string) ); # this should work (as before saved): &$hash{'code'}(); # the two subs sub toStr { use B::Deparse; return B::Deparse->new("-p", "-sC")->coderef2text( shift )."\n"; } sub toCode { 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; }