Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] How do I see a global variable from modules?

Expand Messages
  • Stef
    interrobang mentioned : = My main program, index.cgi, has a line near the top that says use = Schedule.pm; . Inside Schedule.pm, I want to refer to my root
    Message 1 of 2 , Feb 1, 2006
    • 0 Attachment
      interrobang mentioned :
      => My main program, index.cgi, has a line near the top that says "use
      => Schedule.pm;". Inside Schedule.pm, I want to refer to my root
      => folder. So, I tried to use $sitepath. But it's not defined in
      => Schedule.pm!

      I think it will work if you define the global
      variable like this (see perldoc perlmod) :

      testmod.pm :
      sub modsub {
      print "Mainvar : ",$main::mainvar,"\n";
      }
      1;


      testmod_main.pl :
      #!/usr/bin/perl -w

      use strict;
      use testmod;
      local $main::mainvar = "test";
      modsub;


      When modsub is run from the main script, it will show the
      value of the global variable.

      --
      Confidentiality Notice:

      The above message and all attachments may contain privileged and
      confidential information intended only for the person or entity to which it
      is addressed. Any review, retransmission, dissemination, copy or other use
      of, or taking of any action in reliance upon this information by persons or
      entities other than the intended recipient is prohibited. If you received
      this message in error, please notify the sender immediately by e-mail,
      facsimile or telephone and thereafter delete the material from your
      computer. Any views expressed in this message are those of the individual
      sender, except where the sender specifically states them to be the view of
      the entity transmitting the message. UCS Group Limited and all of its
      subsidiary companies hereby distances itself from and accepts no liability
      in respect of the unauthorized use of its e-mail facility or the sending of
      e-mail communications for other than strictly business purposes
    Your message has been successfully submitted and would be delivered to recipients shortly.