On Feb 27, 2004, at 6:55 AM, Michael C. Davis wrote:

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.

Obviously, you can always use parens to make statements unambiguous, as you've demonstrated. I add parens to any subroutine I define. It helps me tell them from the built-ins, among other things.


In the specific case you show though, constants, I prefer a different answer:

use constant DEBUG => 2;

For details on that, try feeding your command line:

perldoc constant

Hope that helps.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to