2-2 純?:??

Fƭȥ~Ar]Oݩ Perl ¶qƫACѩ Perl ̱jj\NbrBzPA]rO@ӫܭnOC

b Perl Ajr곣޸]Double Quote^ӬɩwAӦb޸ܼơAh|QNܼƭȡAҦpG

$name = "Timmy"; # $name ȬO "Timmy" $str1 =My name is $name"; # $str1 ȬO "My name is Timmy" bWҤAYƱ $name ȳQN "Timmy"Ahڭ̥ib $name e[W@Ӥϱ׽uG $str2 = "My name is \$name"; # $str2 ȬO "My name is $name" t@ا@kAhOH޸]Single Quote^ӬɩwrA Perl N|䤺ܼƶiNAҦpG $str3 = 'My name is $name'; # $str3 ȬO "My name is $name" YnNr۳sAiΥyIŸApUG $str4 = "Timmy is " . (2*5) . "years old"; # $str4 ȬO "Timmy is 10 years old" Ъ`NbWҤA(2*5) OƭȹBA䵲Gƭ 10APerl |Nƭ 10 নr "10"AAirsʧ@CyܻAPerl |i楲nഫAƭȩMrVXBAQC

AiH length ƨӭprꪺסAҦpG

$leng = length($str4); # p $str4 סAǦ^ȬO 21 A]iHΡuxvBӶirꪺơAҦpG $name = "Roger"; $repeat = $name x 3; # $repeat ȬO "RogerRogerRoger" ѩuxvBOeB⤸ݦOrA᭱B⤸ݦOƭȡ]YƦơ^A]ڭ̷|UCGG $str5 = (1+2) x 4; # $str5 ȬO "3333" $str6 = 4 x (1+2); # $str6 ȬO "444" oAAݥXF䤤DzFܡH

Perl 䴩Hϱ׽u}lSrAiHCpUG

Ÿ
\aan
\bh]Backspace^
\eEscape
\fFormfeed
\n]Return^
\tw]Tab^
\cJrAҥN Control-J
\xA16 iOAA16 = 1010 = r
\0128 iOA128 = 1010 = r
\\ϱ׽u
\"޸
\'޸
\lU@Ӧrאּpg
\uU@Ӧrאּjg
\LѤU@Ӧr}lA\EΦr굲mAאּpg
\UѤU@Ӧr}lA\EΦr굲mAאּjg
\E \L \U ĥ

UC{XO Perl riUؤjpgܴҤlG

$name = "Roger"; $name1 = "\U$name"; # $name1 ȬO "ROGER" $name2 = "\L$name1"; # $name2 ȬO "roger" $name3 = "\u$name2"; # $name3 ȬO "Roger" $name4 = "\l$name1"; # $name4 ȬO "rOGER" HUO@Ӥppյ{ACX@Ǧۦꪺ]w覡]tstring.pl^AѦUṴ̄ѦҡG

lɡ]tstring.pl^G]ǦϰUYi^
$str1 = 'hello\n';
$str2 = "hello\n";
$str3 = "don't";
$str4 = "a string: \"test\"";
$str5 = "sprite\tcoke";	
$path1 = "c:\\winnt\\temp\\";	# Win32 |ܪk
$path2 = 'c:\winnt\temp';	# Win32 |ܪk
$path3 = 'c:/winnt/temp';	#  UNIX |ܪk
$path4 = "${path1}roger";
$path5 = $path2 . "\\roger";

# LXUӦr
print("\$str1 = $str1\n");
print("\$str2 = $str2\n");
print("\$str3 = $str3\n");
print("\$str4 = $str4\n");
print("\$str5 = $str5\n");
print("\$path1 = $path1\n");
print("\$path2 = $path2\n");
print("\$path3 = $path3\n");
print("\$path4 = $path4\n");
print("\$path5 = $path5\n");

LXĪGpUG

$str1 = hello\n $str2 = hello $str3 = don't $str4 = a string: "test" $str5 = sprite coke $path1 = c:\winnt\temp\ $path2 = c:\winnt\temp $path3 = c:/winnt/temp $path4 = c:\winnt\temp\roger $path5 = c:\winnt\temp\roger pGA Perl Bzrꪺ覡ҺøqAiHQWzp{ӶiաC

PrBzơAiHCpUG

Ÿ
chomprݪr
choprݪr
chrN ASCII NXഫܦr
cryptr[K
hexN 16 iܪrରƭ
indexǦ^@rbt@ۦX{Ĥ@Ӧm
lcରpgr
lcfirstĤ@Ӧrରpgr
lengthpr
octN 8 iܪrରƭ
ordNrഫƭȡ]ASCII NX Unicode^
packNƭȩΦriUYPഫ
q/STRING/
qq/STRING/
reverseNۦꥪkA
rindexǦ^@rbt@ۦX{̫@Ӧm
sprintfǦ^ printf ҧΦr
substrXlr
tr///rഫB]Transliteral Operation^
ucNrܦjg
ucfirstNrꪺĤ@Ӧrܦjg
y///rഫB]Transliteral Operation^

YoǨƪΪkAѡAi perldoc ӨouWAҦpAŪ ucfirst uWAibqROJ

perldoc -f ucfirst ХߨոլݡI

ڭ̥iΦrŪLJAҦpG

$a = <STDIN>; # qL]YзǿJ˸mASTDIN^o@CrJ chomp($a); # RJrݪŸ WzdҤ]iHX@C{XG chomp($a = <STDIN>); YnN@ɮס]test.txt^ev@ŪXAiΤUC{XG open(FILE, "test.txt") || die("Cannot open file"); $line = <FILE>; while (defined($line)) { print "$line"; $line = <FILE>; } 䤤Ĥ@CԭzOѨӨƩҺcAAѡu||v]NuΡv޿B^ӳsCuopen(File, "test.txt")vO} test.txt ɮסAñNɮ׫г]w FILEFudie("Cannot open file")vhOLX Cannot open file ~TAøX{XCyܻAYQ}ɮסAh open ƶǦ^ 1Ah Perl A die ơA]CԭzѡuΡv޿BҺcAun@̬ 1AYiMwӱԭzȡCϤAY open ƶǦ^s]N}ɮץѡ^Ah Perl |A die ơAwTODoӱԭz޿ȡCu$line = <FILE>vhOvqɮŪX@CAɮ׵AY $line LwqA defined($line) Ǧ^ 0 C
Perl