in reply to Coderef from scalar.

Contrary to the above two answers, you don't need eval to build a code ref. Just an anonymous sub will do it:

my $code = sub { print "hello perlmonks\n"; }; # &specialfunction($code);
More can be found in perlman:perlref. Look at the section titled "Making references".

HTH

Replies are listed 'Best First'.
Re: Re: Coderef from scalar.
by vaevictus (Pilgrim) on Dec 29, 2001 at 05:11 UTC
    $code *must* start out as a string of characters that are legal perlcode.