Perl ±N¼ÆÈ©M¦r¦êµø¬°¤@Åé¡A¨Ã·|¦Û¦æ¶i¦æ¥²n¤§Âà´«¡A¨Ò¦p¡G$str = "XYZ" . (3*4*5); Perl ¬Ý¨ì¡u.¡v¡Aª¾¹Dn¶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ª¾¹Dn¶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!"¡Gif (20 lt 8) { print("20 lt 8 is also true!"); } ¦b¥¼¶i¦æ³]©w¤§«e¡A¼ÆÈÅܼƪº¹w³]ȬO 0¡A¦Ó¦r¦êÅܼƪº¹w³]ȬO ""¡]ªÅ¦r¦ê¡^¡CYÅÜ¼Æ $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¡Gperl -w myprogram.pl
Perl