Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scope in packages

Status
Not open for further replies.

jez

Programmer
Apr 24, 2001
370
VN
Hi everyone.

I am just looking for clarification on a scope issue.

I have my perl file which is writing some XML based on some inputs. I have got a whole bunch of default values in a .pm file.

For info my script is called VO_delivery.pl
and my package is called VO_delivery_xml_config.pm


In my main script i am using
Code:
use strict;
use VO_delivery_xml_config;

Then when i use a variable from the package it is in the following form:
Code:
$VO_delivery_xml_config::outputFolder;
for a variable called outputFolder

In the package file is it correct to use 'our' for the variable declaration or should i use 'my'.

I have looked at the documentation on this and i think this is the right way to do it, but not sure.

Any tips on this or even links to a good explanation of scope would be greatly appreciated.

Thanks,

Jez

 
Yes, 'our' is the correct way to go (hence 'our $VERSION'). If you did it with 'my', then $VO_delivery_xml_config::eek:utputFolder wouldn't work.

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top