daily notes[3]
文章目录
- perl notes
- references
perl notes
- typing
perl program_name
on the terminal can run a perl program(script) named program_name. - the following set of codes was replaces by
use v5.35;
at the 5.35 version or more than it.
use strict;
use warnings;
- annotation in perl language is flaged as
#
immediately before annotated content. - print funtion achieves the ouput task ,for example,
print "hello,world"
. $
closely followed by variable name illustrates that is a scalar variable such as$x
,$y
and so on.my
keyword is used to declare a variable such asmy $x=11;
@
indicates the following variable is array. for example:
my @nums=(11,22,33);
print $nums[0];
by the way,$#nums
represent the index of last element in nums
array.
7. %
used to denote the definition of hash .
my %nums = ("one", 1, "two", 2);
my %fruit_color = (one => 1,two => 2,
);
get value through the key in hash can use the following code.
$fruit_color{"two"};
- the
if
statement constructs mutiple conditions flow.
if ( condition1 ) {...
} elsif ( condition2 ) {...
} else {...
}
references
- https://www.perl.org/docs.html