Hello,
I'm trying to use Class::Accessor to make accessors in a package inside the same file that my main script is, but apparently doesn't work. I reduced to a simple case:
#!/usr/bin/env perl use strict; use warnings; my $a = A->new({ hi => 'oi' }); print $a->hello."\n"; print $a->hi."\n"; package A; use base qw(Class::Accessor); A->mk_accessors(qw(hi)); sub hello { return "hello"; }
When I split package A into A.pm (adding '1;' at the end and 'use A;' in the main script) it works fine.
Am I missing something? Does Class::Accessor expect some kind of processing that only happens when the package is in a separate file? Are there alternatives that work with this setup (packages and main script together)?
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |