I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2006-02-02 21:41:16-08 by earl
When are Getters defined?

I'm curious; I want to understand when the Getter is defined. I'm using Object::InsideOut v1.33.

This is Foo.pm.
package Foo; use Object::InsideOut; my %goo :Field('Get' => 'get_goo'); warn(defined(&Foo::get_goo) ? 'yes' : 'no'); 1;

I define a subroutine called Foo::get_goo and I check to make sure it is defined.

And this is the main script

#!/usr/bin/perl -w use Foo; warn(defined(&Foo::get_goo) ? 'yes' : 'no'); print "hello.\n";

Here, I check again to make sure Foo::get_goo is defined. When I run this script I get ...

perl test17.pl no at Foo.pm line 6. yes at test17.pl line 4. hello.
Why isn't Foo::get_goo defined within the Foo package? Earl
Direct Responses: 1752 | Write a response
Posted on 2006-02-03 15:00:53-08 by jdhedden in response to 1748
Re: When are Getters defined?
The sequence is:
1. During the BEGIN phase, Foo.pm is loaded and its warning statement is executed.
2. During the CHECK phase, accessors are generated.
3. During the 'run' phase, the warning statement in 'main' is executed.

Accessors are also generated, if needed, the first time a 'new' call is made. This handles the cases when fields are dynamically generated using 'create_field', when loading is delayed via 'require', and when used under 'mod_perl'.

See 'perldoc perlmod' for info on the various phases.
Direct Responses: Write a response