开发者

how to call a function on a Perl Smart::Comment?

开发者 https://www.devze.com 2023-02-14 00:02 出处:网络
Consider the following Perl code: use Smart::Comments; print \"${ \\return_hello() }\\n\"; ### ${ \\return_hello() }

Consider the following Perl code:

use Smart::Comments;
print "${ \return_hello() }\n";
### ${ \return_hello() }
sub return_hello {return 'hello'}

produces the output:

hello

### ${ \return_hello() }

How could I call the return_hello function right 开发者_如何转开发on the smart comment to get it to print hello?


Looks like Smart::Comments needs a little help to determine that a subroutine should be called. Adding a label seems to work:

### returns: return_hello()

which prints:

### returns: 'hello'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号