Re: How to check if a function reference is valid or not?



On Wednesday 28 November 2007 04:14, Jeff Pang wrote:

for (keys %::) {
print "$_ -> $::{$_}\n" if /abc/;
}

__END__

the output is:
abcee -> *main::abcee
abc -> *main::abc

that's to say, when you say $f2 = \&abcee you have created an entry
in this script's symbol table.

Correct.

so, abcee can be anything (a hash, an
array, a scalar, a subroutine, a handler etc).

No, it is assigning a code reference so only the *main::abcee{CODE}
slot in the symbol table will be in use.

If you had said:

use vars '*abcee';

then abcee could be anything.




John
--
use Perl;
program
fulfillment
.



Relevant Pages

  • Possible bug?
    ... with the key/value pairs in the %Config hash that is used with Config.pm, ... This was on a older version of RH Linux and perl ... keys and the values for the calls I wanted. ...
    (comp.lang.perl.misc)
  • Re: Why are there no ordered dictionaries?
    ... Append it to the sequence of keys. ... > I think this is also the behavior of associative arrays in PHP or Perl ... and we could put the resulting package on the Cheese Shop. ...
    (comp.lang.python)
  • Re: Why are there no ordered dictionaries?
    ... >> sure didn't back when I used Perl! ... > the language provides a ksortfunction to order the keys. ... > cheese shop if they were looking for ordered dicts. ... the stdlib even bigger has a cost...). ...
    (comp.lang.python)
  • Re: Array and Hash able manipulation
    ... given a different source XML file: ... I need to be able to print the names of the keys out without ... server'ness of Perl made me come back. ... The Hash refs and Array ...
    (perl.beginners)
  • Re: How can I Sort hash in numeric context
    ... hashes don't work like this in Perl or in most other languages. ... perldoc -f sort and perldoc -f keys for some hints. ... you'll have to ask the hash for its keys and sort the keys. ... If you'd like to maintain the order of hash keys, you can keep a sorted copy ...
    (comp.lang.perl.misc)