PERL模块TELNET的问题

来源:百度知道 编辑:UC知道 时间:2024/05/12 15:11:57
我在使用$file->waitfor('/second line/'); 捕获信息时,其中的second line不能用变量代替么?我换成个变量他就报错了,谁有办法解决下,谢谢~

From cpan:
usage: $ok = $obj->waitfor($matchop);
You can specify more than one pattern or string by simply providing multiple Match and/or String named parameters. A $matchop must be a string representing a valid Perl pattern match operator. The $string is just a substring to find in the input stream.

照解释来看可以用变量替代啊~只要变量存的是一个模式匹配操作符就ok。
例如
$str = '/second line/';
$file->waitfor($str);
这样是可行的。
不知道lz想在变量中存什么样的值?