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>; };