|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How do you refer to variables that are in another file
For example, vars.sub conatins this line: Code:
... $WebsiteName = "foo"; ... And the file im using has this: Code:
... require 'vars.sub' ... print $WebsiteName; ... The only problem is that, with 'use strict' in there it doesn't work. Taking this out and it does. Having $vars.sub::WebsiteName just makes it print out ".sub::WebsiteName" (without the quotes). |
|
#2
|
||||
|
||||
|
Re: Referring variables in other places
Hi!
I've not tested this example, but I use a similar method in my projects.... What you do is introducing package names. Code:
package Yoursite::Variables; ... $WebsiteName = "foo"; ... Code:
package Yoursite::Printing; ... require 'vars.sub' ... print $Yoursite::Variables::WebsiteName; ... You should continue requiring the subs by filename, this is less ambiguous. Package names you assign don't need to be hierarchical also they don't need to resemble your directory structure. Just be creative. This should allow using strict again. Regards, Atrus.
__________________
Webmaster - Stefan Meier KG TABAKWAREN - Pfeifen, Premium-Zigarren, ... (_Ger) |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Referring variables in other places |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|