What are the basic data types of Perl
This article is about what the basic data types of Perl are. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Basic data types:
Scalar, array, hash, function
$, @,%, &
Scalar, indicator: $
My $aim
$aim = 10000000000; # Integer
My $act = 1.5; # floating point number
$act = 1.5eCo10; # floating point number
My $gain = "4jue 5000w"; # string
$gain = 'Novo gene'; # string
My $reality = undef; # is equivalent to my $reality
Single and double quotation marks:
My $pay = 6000
Print "The pay is $pay\ n"
# display: The pay is 6000
Print 'The pay is $pay\ n'
# display: The pay is $pay\ n
Print "The pay is\ $$pay\ n"; # use "\"
# display: The pay is $6000
"\ n" line break; "\ t" tab
Array, indicator: @
My @ array = (1, 2, 3, 4)
@ array= (1.. 4)
Print "@ array\ n"; # shows: 1 2 3 4
Print the first element of the array array:
Print "$array [0]\ n"; # shows: 1, the array index number starts at 0
Assign the last element of the array to 10:
$array [- 1] = 10; # @ array: (1, 2, 3, 10)
My @ array2 = ("a", "b", "c", 1, 2)
@ array2= qw (a b c 1 2)
Hash (hash, associative array), indicator:%
Characteristics: key (key) = > value (value); key and value correspond one to one
My hash
% hash = (a = > 1, b = > 2, c = > 3)
Print $hash {a}; # shows: 1
Print "b = > $hash {b}\ n"; # shows: B = > 2
% hash = ('averse, 1,' baked, 2, 'cached, 3)
$hash {d} = 1
Thank you for reading! This is the end of this article on "what are the basic data types of Perl?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!