Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

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

Typically the calls will either wind up (at least in my code) being a pass-through hash, or else I will just use a few of the possible options in any particular code.

In which case you're really only passing a single arg - the hash ref :-)

I still think it's better to pass  foo($bar, $baz, \@quux) and then operate on the array ref than  foo($bar, $baz, @quux) and shift through the last args. If nothing else it'll be faster to call by reference.

But really, my complaint is for things like:   $newhash = session::create_hash($sha, $userid, $come_from, $go_to, $sessionid, $time, $hash_secret); which could very well benefit from not having to pass in things which are almost always constant ($sha and $hash_secret), and which could be turned into an object and reduced to

$newhash = $session->create_hash($come_from, $go_to, $time);

which is much more readable.

and yes, $time would be an optional argument -

sub create_hash{ my ($self, $from, $to, $time) = @_; unless($time){ $time = time(); }

variable argument lists - where all the args are basically the same thing to operate on are no problem. It's when you have lots of args which are all required (and different) that the sub gets really hard to use. Trying to remember 12 arguments, all of which are required just isn't going to work. Even if you do named arguments. On the other hand, I do agree that named args might be useful for optional args.

In reply to Re: Re (tilly) 3: Poor Man's Prototyping? by edebill
in thread Poor Man's Prototyping? by tame1

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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-23 14:19 GMT
Find Nodes?
    Voting Booth?

    No recent polls found