http://qs321.pair.com?node_id=225030


in reply to MOPT-04 - identification, part 2

Perl's function bindings are statically scoped, not dynamically scoped, so we can't bind the name to a new entity in a different evaluation context.

You can, of course, do:

sub func { return "original value.\n" } sub print_func { print func(), " "; } sub redefine_func { local *func = sub { return ("local value.\n") }; print_func(); }

Which is still binding an identifier to an entity by your definitions (I think :-)

Replies are listed 'Best First'.
Re2: MOPT-04 - identification, part 2
by mstone (Deacon) on Jan 08, 2003 at 01:59 UTC

    well darned if you aren't right..

    The syntax you used does exactly the same thing as a standard function definition, except it does it locally. By all rights, defining a function with a name should be syntactic sugar for assigning an anonymous subroutine to a typeglob. Apparently it isn't, and I missed it.

    Bravo.. I stand corrected. And so does the article.