项目可能的需要,重温了下Perl,顺便为了帮忙没有接触过的同事,写了这个东西。
尽可能在短的时间,掌握这个语言,并且可以开发项目。大概分成5部分,
这是第一部分,简单介绍了变量,运算符,用户输入的内容。
前提,从 http://padre.perlide.org/ 下载一个Windows版本的Perl IDE。
#!/usr/bin/perl
# http://padre.perlide.org/
# STEP1, 变量定义
print "=================================================\n";
print "变量\n";
print "=================================================\n";
#变量的初始化
$MY_PARA_001=20;
$MY_PARA_002="Hello world!";
#单引号,双引号的区别,双引号有转义,变量。单引号直接输出
print '$MY_PARA_002 LALAL : $MY_PARA_001 \n';
print "\n$MY_PARA_002 LALAL : $MY_PARA_001 \n";
$x = 8;$y = 5;
#数学运算
$res = $x + $y;
print "Result : $res \n";
$res = $x - $y;
print "Result : $res \n";
$res = $x * $y;
print "Result : $res \n";
$res = $x / $y;
print "Result : $res \n";
$res = $x % $y;
print "Result : $res \n";
$res = $x ** $y;
print "Result : $res \n";
#赋值+数学运算
$x+=5;
print '$x+=5 : $x = $x + 5 ,' . "\nResult : $x ; " . ' # $x+=5;$x-=5;$x/=5...' ."\n\n";
if($x > 0 and $x/$y >= 1){
print "Number Logic : >,==,<,>=,!=\n"; #数字比较
print "Logic : and or not\n"; #逻辑运算
}
$str1 = "Hello";
$str2 = "World";
if($str2 ne $str1){
print "String Logic : eq,lt,gt,le,ge\n"; #文字比较
}
#等待控制台输入
print "=================================================\n";
print "Read from Input\n";
print "=================================================\n";
print "Input Something PLS : ";
$str = <stdin>;
print "Input : $str";