构造`<DATA>`,`chomp`和`shift`在这个文件读取功能中做了什么?

use*_*609 -1 perl

我正在使用现有的函数来读取文件.

sub testRead {
    my $file = shift;
    open(DATA, "$file") || die "Can not open $file: $!";

    my $title = <DATA>;
    chomp($title);
    my @names = split(/\t/, $title);
    shift(@names);

    my @data = ();
    my $row = 0;
    while(<DATA>) {
        chomp;
        my @line = split(/\t/);
        for my $i (1 .. $#line) {
            $data[$i-1][$row] = $line[$i];
        }
        $row ++;
    }

    close DATA;
    return (\@data, \@names);
}
Run Code Online (Sandbox Code Playgroud)

我一般可以理解这个功能是做什么的,但我不太确定my $title = <DATA>;.我知道<DATA>代表文件句柄,但这行代码到底要做什么?此外,做什么chomp($title);shift(@names);打算做什么?而且,在while(<DATA>)循环中,有一行代码chomp;,它有什么作用?

zgp*_*max 6

但我不太确定以下几行代码:

my $title = <DATA>; 
Run Code Online (Sandbox Code Playgroud)

我知道代表文件处理程序,但这行代码到底要做什么?

http://perldoc.perl.org/perlop.html#I/O-Operators

另外,chomp($ title); 并转移(@names); 目的是运作?

http://perldoc.perl.org/functions/chomp.html

http://perldoc.perl.org/functions/shift.html

而且,在while循环中(",有单行代码"chomp;",它做什么?

http://perldoc.perl.org/functions/chomp.html