如何只读取文件的第一行 [英] How to read only the first line of a file
本文介绍了如何只读取文件的第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经搜索了一段时间,但是找不到仅读取文件第一行的函数.
I've been googling for a while, but I cannot find a function the read just first line of a file.
我需要阅读文本文件的第一行并从中提取日期.
I need to read first line of a text file and extract the date from it.
Perl的新手.
推荐答案
open my $file, '<', "filename.txt";
my $firstLine = <$file>;
close $file;
这篇关于如何只读取文件的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文