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
A Perl variable name starts with either $, @ or % followed by zero or more letters, underscores, and digits (0 to 9). Perl does not allow punctuation characters such as @, $, and % within identifiers. Perl is a case sensitive programming language.
Perl has three data types: scalars, arrays of scalars, and associative arrays of scalars. Normal arrays are indexed by number, and associative arrays by string. The interpretation of operations and values in perl sometimes depends on the requirements of the context around the operation or value.
Perl has three basic data types: scalars, arrays of scalars, and hashes of scalars, also known as associative arrays. Here is a little detail about these data types.
A scalar variable will precede by a dollar sign ($) and it can store either a number, a string, or a reference. An array variable will precede by sign @ and it will store ordered lists of scalars. Finaly, the Hash variable will precede by sign % and will be used to store sets of key/value pairs.
Quoting the doc:
The
__DATA__
token tells the perl compiler that the perl code for compilation is finished.Everything after the
__DATA__
token is available for reading via the filehandleFOOBAR::DATA
, whereFOOBAR
is the name of the current package when the__DATA__
token is reached.This works just the same as
__END__
does in package 'main', but for other modules data after__END__
is not automatically retrievable, whereas data after__DATA__
is.
Can add to this only that using __DATA__
section is quite handy to illustrate some file reading-related concepts in Perl. it's basically a file attached to a code, and contents of this file are easily accessible through <DATA>
. That's why it's quite popular here on SO. )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With