in reply to Re: Hash key string restrictions?[THANKS]
in thread Hash key string restrictions?

Yup! Assuming the evaled code returns a code ref,
my $code_ref = $code_cache{$code} ||= eval $code; die("Unable to compile and run code: $@\n)" if !$code_ref; $code_ref->();

Replies are listed 'Best First'.
Re^3: Hash key string restrictions?[THANKS]
by Ojosh!ro (Beadle) on Feb 10, 2007 at 12:45 UTC
    That was the basic idea,
    ( the ||= eval $code part would also be stored in the %code_cache )
      The statement I provided *does* store the result in %code_cache. Note the usage of ||= instead of ||.