Questions tagged «slurp»

17
在Perl中,如何将整个文件读取为字符串?
我正在尝试打开.html文件作为一个大的长字符串。这是我得到的: open(FILE, 'index.html') or die "Can't read file 'filename' [$!]\n"; $document = <FILE>; close (FILE); print $document; 结果是: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN 但是,我希望结果看起来像: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 这样,我可以更轻松地搜索整个文档。
118 string  perl  slurp 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.