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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of our in package

Status
Not open for further replies.

uida1154

Programmer
Mar 1, 2004
163
NL
Hi dudes,

I am using an our in a package but somehow something is wrong if I use the package. I receive the following message:


Bareword "our" not allowed while "strict subs" in use at Trace.pm line 32.
Global symbol "$max_trace_level" requires explicit package name at Trace.pm line 32.


Note that the package is called Trace.pm and the variable is declared within Trace.pm as:

Code:
our $max_trace_level

Tell me, what could be wrong?
 
What's your version of Perl?

Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Yeah, I see where Mike's going with this. The 'our' keyword was introduced in, what, 5.6.0? The parser from a previous version would just pick it up as another bareword. Back then, the only real option was a 'use vars' directive. 'our' works differently from 'my' and 'use vars' so while the latter is most likely the patch, there's a chance it might not.

________________________________________
Andrew - Perl Monkey
 
my $max_trace_level;

or

local $max_trace_level;

---------------------------------------
If you helped... thx.
 
Like I said, the use vars pragma is probably what you need.

________________________________________
Andrew - Perl Monkey
 
Is installing the latest version of Perl a reasonable option?

Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Many times there's multiple versions installed. A very early version of Perl 5 is at /usr/bin/perl, but the newer version installed from a package goes into /usr/local/bin/perl. Check your system (or with your system administrator) to see.

________________________________________
Andrew - Perl Monkey
 
Sorry for my late replay but I was out of town.

Installing a later version of perl is not an option, since the intire company should step over then.

I have decided to rebuilt the module using local, works fine.

Thanx all for your help.
 
Just for info: switched back to my at the end. But thanx anyway.
 
try changing $max_trace_level to $maxtracelevel


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top