in reply to How to initialize a Global in a module

I think i have a basic misunderstanding when the module code is executed and the exported variable $_POST is initialized.

Directly after use YourModule; is parsed, perl search for that module, compiles it and runs its mainline, including the initialization of $_POST.

Minimal-ish example:

$ cat A.pm package A; use strict; use warnings; use Exporter qw/import/; our @EXPORT = qw/$_POST/; our $_POST = 42; 1; $ perl -I. -wE 'use A; say $_POST' 42

Replies are listed 'Best First'.
Re^2: How to initialize a Global in a module
by Henric (Initiate) on Oct 26, 2011 at 12:43 UTC

    Thanks a lot ... OK, then it can't work this way ... But how can I achieve the desired behaviour ?