开发者

How to call a function inside qw() in perl?

开发者 https://www.devze.com 2023-03-09 03:59 出处:网络
I have a function get_text() which parses text from XML. I want the text with quot开发者_如何学Ces also.

I have a function get_text() which parses text from XML. I want the text with quot开发者_如何学Ces also. I tried:

qw($self->get_text()); 

It's actually printing "$self->get_text()" & not calling the function. What to do ?


You can't use qw for that, but you can do the same whitespace splitting that qw does with:

@parts = split ' ', $self->get_text();

But your "I want the text with quotes also" makes me think you might be looking for something very different. Can you show an example of what get_text returns and what you want it changed into?


I think you're confused as to what qw does, and when to use it.

http://perldoc.perl.org/perlop.html#Quote-Like-Operators


It's hard to tell what you're asking. qw/.../ is a quoting operator, the effect of which is identical to split ' ', '...'. If you want to split a string in the same way as qw, use split.

0

精彩评论

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