Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Your first output doesn't match your first program, since the variable $test is not printed in the BEGIN block. I suppose this is because you couldn't compile with strict, the solution to that is to declare the variable with our (which will just alias $test to $main::test). Having lexicals override package variables, and our variables (locally aliased? I can't remember if there's a standard name for those) is true even without the -s switch. Actually the $test in the BEGIN block and the $test after the my declaration are two different variables that happen to have the same name. Without strict, the fact that a -s variable is a package global can be implicit.

On the main subject now, on whether -s should be used/kept: I like that perl allows unsafe but useful features that you can use for oneliners and other throwaway code. So having an option with some caveats is OK for me, I just try to avoid them when I'm not writing in a console. The thing is, having a "rudimentary switch" mechanism for any kind of program means that you intend to use it several times, or even that you may not be the only one to use it. For me this is not compatible with the shortcomings of -s, so I would never use it. But I like how perl's philosophy is to "give the user enough rope to hang themselves" but tell them how to avoid the pitfalls, rather than try to secure everything and remove the need for a better understanding. So remove -s, why not? But since it is little known option, and it does have its advantages when used correctly, I don't think it's that much of a hazard (unlike <> or the two parameters open, which are not only really common, but also more standard).


In reply to Re: about perl -s switch -- usable? evil? unneeded? by Eily
in thread about perl -s switch -- usable? evil? unneeded? by Discipulus

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 goofing around in the Monastery: (6)
As of 2024-03-28 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found