mcps5601 / Perl-notes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Perl-notes

Print

#!/usr/bin/perl
$hello = "Hello World";
print "$hello\n"; # 記得加上換行符號

你也可以

#!/usr/bin/perl
use 5.010;
$hello = "Hello World";
say "$hello"; # say幫你省去換行符號

Concatenation

print "hello" . "world" # "helloworld"
print "Dean"x3 . "\n"; # DeanDeanDean

Symbols for comparison

Symbols String
== eq
!= ne
< lt
> gt
<= le
>= ge

if-else

$line = <STDIN>;
if ($line eq "\n"){
    print "只是一個空列 !\n";
}
else {
    print "該列所輸入的是: $line";
}

About