从抓取网站,我在标量变量$ res中有一个html文件。 我想逐行读取$ res中的html文件。例如,while(my $ line =)...
我是否需要将$ res打印到文本文件然后读入文本文件?
答案 0 :(得分:0)
您可以使用IO::Scalar
模块。
man IO::Scalar
:
use 5.005;
use IO::Scalar;
$data = "My message:\n";
### Open a handle on a string, read it line-by-line, then close it:
$SH = new IO::Scalar \$data;
while (defined($_ = $SH->getline)) {
print "Got line: $_";
}
while(<$SH>)
也有效。
答案 1 :(得分:0)
要解决the Y part of this problem,是的,您可以将标量变量视为输入源并使用Perl的输入处理功能。您只需@implementation CustomCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
NSLog(@"HEIGHT: %f",self.frame.size.height);
// Initialization code
[self.contentView setFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, kDefaultTableViewCellHeight)];
[self setBackgroundColor:[UIColor clearColor]];
[self createViews];
}
return self;
}
对变量的引用:
open