[prev in list] [next in list] [prev in thread] [next in thread]
List: perl-beginners
Subject: Re: separating code in two files
From: Chris Stinemetz <chrisstinemetz () gmail ! com>
Date: 2013-02-28 19:34:15
Message-ID: CA+Hbpzhhj+zO4jxvM0==RqEvA+Re8T-2f0pFPbaUyTQQN+So=g () mail ! gmail ! com
[Download RAW message or body]
>
>
>
> Put the following line in the main script:
>
> our %hash;
>
> Change the "my %hash = ( ... );" declaration in lib.pl to "our %hash =
> (...);".
>
> In your original versions, %hash was a lexical variable in lib.pl, and
> thus not in scope within perl.pl. Using 'our' instead of 'my' makes %hash
> a package variable (in package main::), and as such is accessible by both
> perl.pl and lib.pl, The 'our' declaration also lets you leave off the
> package name when you access the variable.
>
>
>
Thank you very much! That did the trick.
Chris
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic