2-3 ƭȩMrꪺP

Perl ±N¼Æ­È©M¦r¦êµø¬°¤@Åé¡A¨Ã·|¦Û¦æ¶i¦æ¥²­n¤§Âà´«¡A¨Ò¦p¡G $str = "XYZ" . (3*4*5); Perl ¬Ý¨ì¡u.¡v¡Aª¾¹D­n¶i¦æ¦Û¦êªº³sµ²¡A©Ò¥H·|¥ý¶i¦æ 3*4*5 ªº¼Æ­È¹Bºâ¡A±o¨ì 60¡A¦A±N¤§Âà´«¦¨¦r¦ê "60"¡A³Ì«á©M "XYZ" ³sµ²¦b¤@°_¡A¦]¦¹ $str ªº­È´N¬O "XYZ60"¡C¦A¬Ý¬Ý¤U­±¤@­Ó¨Ò¤l¡G $num = "123.45Miracle" + 1; Perl ¬Ý¨ì¥[¸¹¡Aª¾¹D­n¶i¦æ¼Æ­È¥[ªk¡A©Ò¥H·|¥ý±N¦r¦ê "123.45Miracle" Âন¼Æ­È¡A±o¨ì 123.45¡A¦A¥[¤W 1¡A¦]¦¹ $num ³Ì«áªº­È´N¬O 124.45¡C

¤@¯ë¦Ó¨¥¡APerl ·|®Ú¾Ú¹Bºâ¤¸¨Ó§PÂ_¹Bºâ¤¸©Ò»Ýªº¸ê®Æ«¬ºA¡A¨Ó¶i¦æ¦r¦ê©M¼Æ­È¤§¶¡ªº¬Û¤¬Âà´«¡A¨äÂà´«µ²ªG¤j³¡¤À³£¯à²Å¦X¨Ï¥ÎªÌªº»Ý¨D¡C¦ý¦b¨ä¥L¤Ö¼Æ±¡ªp¤U¡A¼Æ­È©M¦r¦êªº³q¥Î©Ê¥i¯à¾É­Pµ{¦¡ªº¿ù»~¡A¦¹®É´N»Ý­nµ{¦¡³]­pªÌªº¤¶¤J¡C

¥H¤U¬O Perl ªº¤ñ¸û¹Bºâ¤¸¡]Comparison Operators¡^¡G

¤ñ¸û¹Bºâ»¡©ú¥Î©ó¼Æ­Èªº¹Bºâ¤¸¥Î©ó¦r¦êªº¹Bºâ¤¸
¬Ûµ¥==eq
¤£¬Ûµ¥!=ne
¤p©ó<lt
¤j©ó>gt
¤p©ó©Îµ¥©ó<=le
¤j©ó©Îµ¥©ó>=ge

¥Ñ©ó¼Æ­È©M¦r¦êªº±Æ§Ç¤èªk¨Ã¤£¬Û¦P¡A¦]¦¹§Ú­Ì¥²¶·¹ï¼Æ­È©M¦r¦ê©w¸q¨â®M¤£¦Pªº¤ñ¸û¹Bºâ¤¸¡C¼Æ­Èªº¤ñ¸û¬O®Ú¾Ú¼Æ­Èªº¤j¤p¡A¦]¦¹¤U¦Cµ{¦¡½Xªº±ø¥ó§PÂ_±N¦¨¥ß¡A¨Ã·|¦L¥X "20 > 8 is true!"¡G

if (20 > 8) { print("20 > 8 is true!"); } ¦Ó¦r¦êªº¤ñ¸û¬O®Ú¾Ú¨ä ASCII ¤º½Xªº¤j¤p¡A¦]¦¹¤U¦Cµ{¦¡½Xªº±ø¥ó§PÂ_¥ç±N¦¨¥ß¡]¥Ñ©ó¹Bºâ¤¸¬O¡ult¡v¡A20 ¤Î 8 ·|³Qµø¬°¦r¦ê¡^¡A¨Ã·|¦L¥X "20 lt 8 is also true!"¡G if (20 lt 8) { print("20 lt 8 is also true!"); } ¦b¥¼¶i¦æ³]©w¤§«e¡A¼Æ­ÈÅܼƪº¹w³]­È¬O 0¡A¦Ó¦r¦êÅܼƪº¹w³]­È¬O ""¡]ªÅ¦r¦ê¡^¡C­YÅÜ¼Æ $x ¥¼©w¸q¡A«h¤U¦Cµ{¦¡½X·|¨Ì¹Bºâ¤¸¦Ó¦³¤£¦P¤§µ²ªG¡G $a = $x + 1; # $x = 0, $a = 1 $str = "Test" . $x; # $x = "", $str = "Test" ­Y§Æ±æ Perl ¯àÀˬd¨ì¥¼©w¸q¤§ÅܼơA«h¥i¥H¦b©I¥s Perl ®É¡A¥[¤J¡u-w¡vªº¿ï¶µ¡]w ¥Nªí warning¡^¡A¨Ò¦p¥i¥Î¤U¦C¤è¦¡¨Ó°õ¦æ myprogram.pl¡G perl -w myprogram.pl
Perl