Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
A few comments:
  • All your subroutine definitions use the "no parameters" prototyping by virtue of adding "()" in their definitions. Indeed none of your subroutines take any parameters, so that is not wrong, but then you call al your subroutines by prepending "&" to their names which has the effect of ignoring any prototypes. It is far better to delete all the prototyping as it probably does not do what you think it does and also delete all the "&" in the sub-calls which serve no purpose here.
  • You have a peculiar way of naming your variables and subroutines. While not "wrong" as such, it is not the perlish way. I wonder what was your native computer language before you started programming in Perl. Anyhow, the use of "::" in variable names and subroutines is reserved for using packages ("namespaces", if you wish), but you do not use packages here and frankly for a program of this size that does not use any modules, it is overkill to use namespaces. Everything can safely live in the main package (which is the default package).
  • Your use of local is ... strange. Did you do it so your program runs under use strict;? Again, probably you have a wrong concept of what local does. If you want to declare global (in the sense of can-be-seen-and-accessed-everywhere) then you can safely use lexical "my" variables, placed outside of any subroutine or block.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James


In reply to Re: ASCII Battleship Program by CountZero
in thread ASCII Battleship Program by perlStuck

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 admiring the Monastery: (5)
As of 2024-04-19 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found