Perl Learning - 1 (Breif introduction, Scalar)

I bought <<Learning Perl>> last year, but just learned to know the surface of what Perl is. One year back, I'll pick it up for second round hoping to catch up the step that QQ group "Linux group" folks are currently on. I don't want to be behind too far away :)
 
For today, I learned about what Perl is, and what Perl does.
 
Whatever name it is, Perl is a computer language Larry wrote to fix his needs. Most offten Perl programs won't be written as a EXE like any other languages do, we call it a script language. From the view what a script language is, Perl is huge.
 
What does Perl do? Perl was designed to fix problems, whatever problem that can be handled by a computer. However, many Perlers said Perl was used to handle text-related issues by 90%. If not all, most of problems in computer world can become test-related. This means Perl can fix most problems that we will/already meet.
 
Why Perl is so powerful? This is not easy to answer. One reason is its Regular-Expression (RE), RE is very powerful to take care of Text, whatever Text it is. Many Perlers say Perl is hard to learn but easy to use. They say Perl is designed for those who will write Perl programs hours every day, not for those who touch Perl minutes per week.
 
Besides those, I learned Perl's scalar variable. Perl's scalar variable should be defined with '$' and '=', both variable and value must be lead with '$'. It's dfferent with Shell script, also not like awk/C.
 
Values of scalar variables typically can be number(s) or character(s). When value is character, it must be quoted by pare of ", or pare of '.  Each Perl sentance will be end wth ;   Examples:
 
$var='hello';
$num=20;
$name="Tom";
 
Values of scalar variables can be inserted to pare of ", but cannot to pare of '. Any character in pare of ' is itself, except ' and \. A ' or \ should be put after a \ in pare of '. Examples:
 
$var="$name";  # Value insert to pare of "
$var='$name';  # Just $name itself
$var='\'$var\' is just $name';
$var='\\ is a single back splash';
 
A useful function print() is almost used in every Perl program. It print all its parameters to STDOUT, which typically is your computer screen. Example:
 
print "Hello World\n";
print "You name is: $name\n";
print 3*5;
 
Characters can be connected with symbol . , numbers can be caculated with symbol  + - * / . Numbers can compare by symbol == !=  >  <  >= <= , characters can compare by symbol eq nq gt ge lt le.
 
eq means "equal";
nq means "not equal";
gt means "greater than";
ge means "greater or equal";
lt means "less than";
le means "less or equal";
 
'b' gt 'a';  # True, character 'b' is greater (comes after) character 'a';
'a' gt 'A'; # True, character 'a' comes after 'A' in ASCII;

你可能感兴趣的:(perl,learning)