"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
G'day jnorden, Welcome to the Monastery. The short answer to your title's question, "Is 'use vars' really obsolete?", is no. The premise of your question seems to be false (or, at least, faulty): your opening quotation (from vars) says "superseded"; nowhere in that documentation does it say "obsolete". You will still find the vars pragma in use. our was introduced in Perl 5.6.0 (see "perl56delta: "our" declarations"). Legacy Perl code written prior to that version would not have had our available; modules aiming for backwards-compatibility with versions earlier than 5.6.0 might use vars. You may well encounter the vars pragma and, as such, you should know about it; however, except in very special cases (such as those cited) you should not use it in new code. Here's more of that quotation from vars (emphasising the points I've made): "... the functionality provided by this pragma has been superseded by our declarations, available in Perl v5.6.0 or later, and use of this pragma is discouraged." Your description of a scenario in which you "don't see an alternative" is unclear. What sort of project is this? What sort of file is it? Why would project size result in a desire for just one file? Is this single file executable? Is the project actually a component of some larger project? I have other questions like those because, as it stands, I'm unable to visualise the code you've attempted to describe. Please read "SSCCE" and "How do I post a question effectively?". As others have mentioned, a coded example will help to clarify what you mean: it will also allow us to suggest alternatives, which currently allude you. — Ken In reply to Re: Is 'use vars' really obsolete?
by kcott
|
|