in reply to Anonymous scalar ref revisited

f(\f)

(not supposed to be serious, but it's elegant at least :)

Replies are listed 'Best First'.
Re^2: Anonymous scalar ref revisited
by rovf (Priest) on Apr 06, 2010 at 11:46 UTC
    Certainly a funny proposal (though it bails out if the subroutine itself is unnamed, but I admit that this is a border case which we will ignore). Still I'm puzzled how this can work. What is the f in this \f supposed to mean? It can't be a reference to the subroutine f, sind this would be \&f and wouldn't be useful either. Hence it must mean that we apply \ to the result of a parameterless invocation of f, but this shouldn't work either. Which hat did you get this f out from?

    -- 
    Ronald Fischer <ynnor@mm.st>
      That works only because f() itself is so simple, and also because

      my $ref=undef; $$ref=4711;
      works too. That's why it's not serious, but also probably answers your question more deeply - you don't need a special syntax for anonymous scalar-ref, it gets autovivified when necessary.