我無法用Perl做出是/否的問題,而我只是無法弄清楚。我很喜歡這個。如果遇到麻煩Perl語句
#! usr/bin/perl
print "Hello there!\n";
print "What is your favorite game?\n";
$name = <STDIN>;
chomp $name;
print "That's awesome! $name is my favorite game too!\n";
print "Do you think this is a fun script (Y/n) \n";
$status = <STDIN>;
if [ $status = "y" ]: then
print "YAY! I knew you would like it!\n";
if [ $status = "n" ]: then
print "You suck, not me!\n";
我在做什麼錯?
如果Perl語句不使用方括號來包含條件,則它們使用括號。他們也不使用'then'關鍵字。 'if($ status eq'y'){} elsif {} else {}' – 2014-10-31 20:48:07