Perl data types
Translation results:
Perl is the abbreviation of Practical Extraction and Report Language, which can be translated as "Practical Report Extraction Language".
Perl is a high-level, general-purpose, literal, dynamic programming language.
Perl was originally designed by Larry Wall and was published on December 18, 1987.
Perl borrows features from C, sed, awk, shell scripts, and many other programming languages.
The most important feature of Perl is that Perl integrates regular expression functions and the huge third-party code library CPAN.
Perl data typessyntax
Perl is a weakly typed language, so variables do not need to be typed, and the Perl interpreter will automatically choose a matching type based on the context.
Perl has three basic data types: scalar, array, and hash.
Perl data typesexample
1 Scalar
Scalar is the simplest data type in Perl language. Variables of this data type can be numbers, strings, floating point numbers, and no strict distinction is made. When using, add a "$" in front of the variable name to indicate that it is a scalar. For example:
$myfirst=123; #Number 123 $mysecond="123"; #String 123
2 Array
Array variables start with the character "@", and the index starts from 0, such as: @arr=(1,2,3)
@arr=(1,2,3)
3 Hash
Hash Is an unordered collection of key/value pairs. The value can be obtained using the key as a subscript. Hash variables start with the character "%".
%h=('a'=>1,'b'=>2);