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 operators of Perl

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

Share

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

This article mainly shows you "What are the basic Perl operators?" The content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn "What are the basic Perl operators?" This article.

numeric operator

+、-、*、/、%、**、++、--、+=、-=、*=、/=

..、.、x、,

@a = (1 .. 4); # @a = (1,2,3,4), note: cannot be from large to small

$s = "Test". 1; # $s = "Test1"

$s .= 2; #$s = "Test12"

@a = (1) x 4; # @a = (1,1,1,1)

$s = "A" x 4; # $s = "AAAA"

my ($a,$b) = (1,2); # my $a = 1; my $b =2;

$a=$b+1,$b=$a+1; # $a=$b+1;$b=$a+1;

($a,$b) = (1,2);

($a,$b) = ($b+1,$a+1); # $a=3, $b=2

#is not equal to: $a=$b+1; $b=$a+1;

logical operators

Logical OR: $a|| $b or $a or $b #either a or b is true

logical AND: $a && $b or $a and $b #true only if both a and b are true

Logic is NOT: ! $a or not $a #a is true when false

Logical XOR: $a xor $b # a, b is true when one is true and one is false

Conditional operators (ternary operators):

Conditions? Value1: Value2. When the condition is true, the value is 1, and when it is false, the value is 2, such as:

$result = ($var == 0) ? 14 : 7;

That's all for "What are the basic Perl operators?" Thanks for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

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