Please have a look at the second: print $hash{code},"\n";
It prints a CODE(0x..)-Ref, but is not executable.
Any Hints,
Thanks,
Carl
#! /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}; }
In reply to Re: Re: Re: Re: save to file: $h{'sub'}=sub{..};
by Anonymous Monk
in thread save to file: $h{'sub'}=sub{..};
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |