logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: Variables in external file: msg#00067

Subject: Re: Variables in external file
Just a quick question. Is it possible to have a bunch of variables in a separate file and then require that file in the script file? Let me give you and example.
[...]
require variables.conf
[...]
variables.conf
[...]
my @list;
[...]
When I try the above script, I get an error - "Global variable @list needs to be defined". What am I doing wrong, or is this even possible?

The scope of my @list is the file where it's declared. From 'perldoc -f my':

A "my" declares the listed variables to be local (lexically) to the enclosing block, file, or "eval". If more than one value
               is listed, the list must be placed in parentheses.

You'll need to declare the variable in the script ('our', not 'my'), before you require variables.conf

Neil





Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>