开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜