in reply to Re: strict and symbolic subroutine refs
in thread strict and symbolic subroutine refs

You could keep a hash of subreferences, and in practice you'll be doing the same thing (the symbol table is a hash),
we're not talking about me having a problem with strict.pm. (1) =)
actually i never used the my $coderef = main->can($subname) thing for projects i'm programming on. just for trying out.
i'm well aware that a hash of subrefs would be the way to go, i just saw that code \&$subname somewhere, and i really never stumbled upon that paragraph in strict.pm where it is documented.
it's just that i usually thought that would require no strict, and i find that in more people's code that they are doing something like that:
no strict; my $ref = \&$name;
so i was really surprised it worked with strict.

(1) i'm using 'no strict' a lot, though, for munging the symbol table (dynmic class generation and things like that)

Replies are listed 'Best First'.
Re^3: strict and symbolic subroutine refs
by nothingmuch (Priest) on Jul 25, 2004 at 07:02 UTC
    I sounded a bit pedantic, I regret to admit.

    What I really meant was that even if no strict is unnecessary, it might be a good idea to put it there so the code is more self documenting, or to use a solution that doesn't need no strict (is that a double negative?), not because it is a better solution, but because it might be more coherent. The code refs in hash was just an example, I guess.

    -nuffin
    zz zZ Z Z #!perl
      I sounded a bit pedantic, I regret to admit.
      no no, i think it's absolutely right to suggest an alternative like coderefs in a hash whenever such a question arises. those who don't know what kind of problems &{'subname'} can bring with it will appreciate it.

      i still wish i head read the docs more carefully before asking and then reading it ten minutes after, but, interesting, after asking around it turns out that i'm not the only one who missed that strict-exception. =)