How can I use macros in Perl?

前端 未结 4 1313
一生所求
一生所求 2021-01-01 05:36

How do I use macros in Perl, like I do in C?

Example:

#define value 100 
print value; 

I want to get the output as 100.

4条回答
  •  無奈伤痛
    2021-01-01 06:10

    For constants, the common way is to use a constant subroutine that will get inlined by the compiler:

    use constant value => 100;
    

    or

    sub value () {100}
    

提交回复
热议问题