Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic data types of Perl

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report