php forum
php mysql forum
php mysql smarty
 
Topic Options
#103710 - 04/05/02 05:40 PM "our" vs. "use vars"
Dave_L Offline
Member

Registered: 08/16/00
Posts: 356
Loc: Virginia, USA
ultimatebb.cgi employs the obsolete "use vars" instead of "our", presumably for compatibility with older Perl versions.

I've used "our" in my scripts, but don't completely understand how it works (although I've mostly been able to get it to work by trial and error).

Is "our" equivalent to "use vars"?

For example, if, on a system running Perl 5.6+, the "use vars qw(%vars_poll ... $title_wording);" in ultimatebb.cgi were replaced with "our (%vars_poll ... $title_wording);", would the script function the same way?

Top
#103711 - 04/06/02 03:36 AM Re: "our" vs. "use vars"
jordo Offline
Moderator / Developer

Registered: 08/05/00
Posts: 830
yes it should, though if it follows the my() pragma, it probably will want comma delimeters. interesting read here as to performance benefits/etc: http://theoryx5.uwinnipeg.ca/guide/performance/Global_vs_Fully_Qualified_Varia.html
_________________________
jordo

Top
#103712 - 04/06/02 07:28 AM Re: "our" vs. "use vars"
Dave_L Offline
Member

Registered: 08/16/00
Posts: 356
Loc: Virginia, USA
You're correct about the commas, I forgot to include them above.

Thanks for the answer and the helpful link.

I think I had misunderstood the function of our. Unlike my, our doesn't allocate space for a variable, it just provides a lexically-scoped alias. Since I generally prefer using fully qualified variables, perhaps I was trying to forcibly use our in situations where it wasn't really needed.

Top
#103713 - 04/06/02 11:32 AM Re: "our" vs. "use vars"
Mark Badolato Offline
P.I.T.A. / Programmer

Registered: 09/08/00
Posts: 836
Loc: Land O' Cactus
Correct... our is for scoping. I believe it can work across packages but to tell you the truth, I don't know for sure because I never use it. All the stuff I do needs to stay compatible with perl versions < 5.6.x so I can't use it
_________________________
"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan

Top



Latest Posts
[7.2.1] - Naked shoutbox
by bellaonline
05/05/12 05:00 PM
[7.x] Stop Forum Spam Integration v0.4
by bellaonline
05/05/12 03:53 PM
Shout Box

(Views)Popular Topics
Known public proxy servers 1689885
Integrated Index Page (IIP) 5.3.1 555705
Finished-[6.5.2] Games Arcade Deluxe v1.9 501236
Integrated Index Page (IIP) 5.1.1 415112
TLD Bv2.1 Released - Threads Links Directory 396822
[6.0x] Who's Online 4.0.0 [Finished] 389412
Finished-[6.5.1] Integrated Index Page (IIP) 6.5 330423
Q & A 298663
Slash UBB 266936
[6.3.x] [beta] Hit Hack 2.0 227970
Forum Stats
13621 Members
59 Forums
37191 Topics
295716 Posts

Max Online: 686 @ 06/28/07 07:04 AM

 

 

 
fusionbb message board php hacks