Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

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

As others wrote already there is no way to make this work. The important thing to remember is that prototypes are NOT subroutine signatures! Prototypes do not exist to allow you to specify the number and type of arguments! They exist to allow you to create (very occasionally) a subroutine that works as a builtin. Take push() for example. If you pass (@arr, 1,2,3) to an ordinary subroutine, then the subroutine receives a list containing all elements in @arr followed by 1, 2 and 3 and has no way to modify the @arr array. push() on the other hand receives the array and then the 1, 2 and 3 and can modify the array.

If for whatever reason you feel the need to create a subroutine that is used the same as push(), you can use a prototype to tell Perl to change the way its parameters are handled, but you should not attempt to use it to validate that a subroutine gets the expected number of parameters!

The only prototype an ordinary programmer should ever use is the empty one for constant subroutines (and even then  use constant ... is better) and MAYBE ($) for subroutines that are to be used in mathematical expressions. All other prototypes are best left to a few module authors.

Jenda
Enoch was right!
Enjoy the last years of Rome.


In reply to Re: effects of ampersand and non ampersand when referencing a sub name by Jenda
in thread effects of ampersand and non ampersand when referencing a sub name by ISAI student

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

    No recent polls found