in reply to Re^4: globally seen variable
in thread globally seen vairable

You need to use our $ERROR_FILE; in each scope in which you need visibility.

Rather than this comment....

## $ERROR_FILE is global var ## open OF, ">>$ERROR_FILE" or die "cannot open ERROR_FILE $ERROR_FILE\n" +;

This serves the same purpose, and gives you that visibility.

our $ERROR_FILE; open OF, ">>$ERROR_FILE" or die "cannot open ERROR_FILE $ERROR_FILE\n" +;

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re^6: globally seen variable
by vit (Friar) on Sep 28, 2010 at 22:11 UTC
    I did it, but it does not pass a value into $ERROR_FILE in the package.
    I defined our $ERROR_FILE in main and assigned a variable to it, not a constant. Is it possible?

      junk.pl:

      #! perl -slw use strict; use Junk; our $ERROR_FILE = 'fred'; Junk::showIt();

      Junk.pm:

      package main; our $ERROR_FILE; package Junk; use strict; use warnings; sub showIt { print $ERROR_FILE; } 1;
      C:\test>junk.pl fred

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.