in reply to Using Class::Accessor with packages in the same file as the main script

Well, solution for my own problem :-), thanks to reading Re: Defining classes and inheritance using packages within a single .pl file, without creating modules.

It ended up to be a simple thing. I must put my package before the main script, something like:

use strict; package A; ... # yada yada yada package main; ...

so it loads properly, or put my package definitions inside BEGIN blocks. By load properly I mean, mk_accessors is called before objects from A are used, so the accessors are there.

  • Comment on Re: Using Class::Accessor with packages in the same file as the main script
  • Download Code

Replies are listed 'Best First'.
Re^2: Using Class::Accessor with packages in the same file as the main script
by betterworld (Curate) on Mar 30, 2007 at 13:03 UTC
    You could alternatively use a BEGIN{} or INIT{} block to call mk_accessors.