> Dan Muey wrote: > > > > In developing a module and I am torn. > > > > I want to use the newer our $variable; but to make it work with pre > > 5.6 Perl (or whatever version our appeared in) I have to do the use > > vars qw($variable); method > > > > So I was wanting some input about pros and cons of using > either since > > on the surface they appear to do the same thing except that > use vars > > is backwards compatable. > > > > Any input on our vs. use vars ?? Pro,con, neutral ?? > > Hi Dan. > > The main issue about 'our' as opposed to 'use vars' is that > the of scope. 'use vars' compiles to a BEGIN block which, > wherever it is used, makes the package variables visible > throughout the file. An 'our' declaration provides access to > a package variable up to the end of the current block or file. > > You can safely use 'our' in place of 'use vars', but not > necessarily vice versa.
Hey Rob, Yes that's helps a lot. So I'm still stuck with wanting to do our but needing backward compatibility. I wonder if I should check the version and do our if it's 5.6 and do use vars if it's older. Except the BEGIN stuff would probably make it not work as expected. Or I could do two versions of the module and folks could install which one they need based on their Perl version. Or I could say "upgrade your Perl!" and just do our! :) Thanks Rob for the info, very helpful as usual! Dan > > HTH, > > Rob > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]