Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我现在正在学习 perl/CGI 并试图弄清楚如何在 perl 中读取文件。我让我的程序将每一行读入新变量。
现在我希望我的程序将第一行读入变量 $first_line 并将文件的其余部分存储到另一个变量 $rest 中。我该怎么做呢?
谢谢
my $first_line = <$file_handle>; # read rest of the file only if first line was read my $rest = defined($first_line) && do { # input record separator set to undef (slurp mode) local $/; <$file_handle>; };