Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

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

I myself am doing the same exact thing as you, basically making my subroutines "generic", (at least any subroutine I write that could ever be used again) more for my own code library and the benefit of the practice than a module or anything, but I haven't really taken the approach of using prototypes. At the mention of making my subroutines generic, my guru suggested using them, but upon my own research, I just didn't see the benefit, seems a bit redundant to me, perhaps I'm missing their functionality/purpose?

Also, just food for thought, in doing this I've found it much easier to write a specific one time sub, then go back and change a few var names/etc to make it generic, than to write it generic the very first time through. I always feel a bit guilty about this, because I instinctively sense the waste of time and redundancy of writing something just to re-write it, but once you've got a huge library of very generic subs, it pays for itself many times over, and saves much more time than it wastes, IMHO anyway.

Oh, and JavaFan, very nice, I've never seen that in a sub prototype, ";" meaning an optional second scalar, I was about to suggest to lyapunov to just use an @ as the prototype, as your second example did, when I saw your reply and learned a new solution. ++


In reply to Re: How do I prototype a function with a varying number of arguments? by koolgirl
in thread How do I prototype a function with a varying number of arguments? by lyapunov

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 avoiding work at the Monastery: (2)
As of 2024-04-26 02:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found