Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^5: How do I prototype a function with a varying number of arguments?

by koolgirl (Hermit)
on Jul 30, 2011 at 02:07 UTC ( #917582=note: print w/replies, xml ) Need Help??


in reply to Re^4: How do I prototype a function with a varying number of arguments?
in thread How do I prototype a function with a varying number of arguments?

oO

Instinctively, I think maybe this is a trick question, but, nonetheless....like this?

&sub ($@[0], $@[1])

I mean, technically a reference to a single array element is a scalar variable, so, that would work then....right?

  • Comment on Re^5: How do I prototype a function with a varying number of arguments?
  • Download Code

Replies are listed 'Best First'.
Re^6: How do I prototype a function with a varying number of arguments?
by chromatic (Archbishop) on Jul 30, 2011 at 08:25 UTC
    I think maybe this is a trick question...

    How do you pass the contents of a two-element array to an unprototyped function which takes two scalar arguments?

    some_func( @two_elements );

    How do you pass the contents of a two-element array to a $$ prototyped function?

    some_func( $two_elements[0], $two_elements[1] );

    That looks less generic to me, as it forces callee details to the caller side.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://917582]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2022-08-18 04:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?