> From: Michael C. Davis [mailto:[EMAIL PROTECTED] > Sent: Friday, 27 February 2004 11:55 PM > To: [EMAIL PROTECTED] > Subject: subroutine call weirdness > > Hi list, > > I just ran across some unexpected results in passing arguments to > user-defined subroutines. Could someone who has been around > Perl a while > longer check this and make sure I'm seeing this right? > > I've got some code that implements a constant as a subroutine > call (to keep > the constant from being modified). When I use that subroutine in an > arithmetic expression, it is consuming everything to the > right of it as its > argument list.
This is correct. That is why Larry said, "Let there be Prototypes". Now remember, a perl 'prototype' is not a prototype in the regular sense, but a method to override perl's natural greedy argument list collection, and a method to create functions which emulate perl's builtins (ie, provide hints to the expected calling context). > sub EarliestValidTimestampAsNumber { > > # pass in 2000-01-01 00:00:00 as timegm expects it > # (i.e. as would be returned by gmtime) > # so that we get correct number of seconds offset from > start of epoch > > return timegm(0, # second zero > 0, # minute zero > 0, # hour zero, on > 1, # the first day of > 0, # January > 100 # 2000 > ); > } might become: sub EarliestValidTimestampAsNumber () { timegm(0,0,0,1,0,100) } Hence, the perl compiler *knows* that no arguments could possibly be passed to the function, and thus none will. Your test cases should now run properly. HTH David Regards, David le Blanc -- Technical Specialist <http://www.identity-solutions.com.au/> I d e n t i t y S o l u t i o n s Level 1 365 Camberwell Road Melbourne Vic 3124 Ph 03 9813 1388 Fax 03 9813 1688 Mobile 0417 595 550 Email [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> The information transmitted is intended only for the recipient(s) to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you have received this in error, please contact the sender and then delete it. Identity Solutions has taken precautions to minimise the risk of transmitting software viruses, but we advise you to carry out your own virus checks on any attachment to this message. Identity Solutions cannot accept liability for any loss or damage caused by software viruses. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>