Beefy Boxes and Bandwidth Generously Provided by pair Networks
"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
in thread Is 'use vars' really obsolete? by jnorden

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (None)
    As of 2024-04-18 23:42 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found