Alex Rivera | Logout

The <DATA> syntax in perl

Asked 2012-11-19T22:31:42.870
32

Where can I find more about the following syntax in perl?

The connection between <DATA> and __DATA__ is unclear.

while (my $date_string = <DATA>) {
  chomp($date_string);
  next if not length $date_string;
  print "$date_string ist Unixtime ",
        $lang_date->str2time($date_string),
        " und ",
    $lang_date->time2str( '%d.%m.%Y %T (%Z)',$lang_date->str2time($date_string) ),
        "\n";
}

__DATA__
1.3.1999
1 Marz 1999
1. Marz 1999
1/3/1999
Edit
Report

1 Answer

7

Everything after __DATA__ is treated as a file you can read from the filehandle DATA. DATA is opened automatically and you don't have to do anything to get it that way.

What isn't clear? Your program seems to be using it properly.

answered 2012-11-19T22:34:13.667

Your Answer