perl practice

Posted MOVIT

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了perl practice相关的知识,希望对你有一定的参考价值。

perl practice

人民币/美金根据汇率进行转换

print<<EOF;

This is a currency convert program;
    
please input the exchange rate and select the local currency;
    
EOF

print "please input the exchange rate between dollar and RMB","\\n";

chomp(my $exchange_rate = <STDIN>);

print "the exchange rate you set is $exchange_rate","\\n";

print "please select RMB or dollar as your local currency","\\n";

chomp(my $currency = <STDIN>);

print "you set $currency as you local currency","\\n";

if($currency eq "RMB") {
    
    print "please input the amount of your local currency","\\n";
    
    chomp(my $amount = <STDIN>);
    
    print "the amount of RMB is $amount","\\n";
    
    print "RMB convert to dollar,the amount is ",$amount/$exchange_rate;
    
} elsif($currency eq "dollar") {
    
    print "please input the amount of your local currency","\\n";
    
    chomp(my $amount = <STDIN>);
    
    print "the amount of dollar is $amount","\\n";
    
    print "dollar convert to RMB,the amount is ",$amount*$exchange_rate;
    
} else {
    
    print "the currency you set is wrong","\\n";
    exit;
    
}

以上是关于perl practice的主要内容,如果未能解决你的问题,请参考以下文章

perl中的队列

perl语言基础命令

Perl 5.20.0 发布

带有动态值的write_rich_string(Perl)

Perl 语言和系统管理——洪峰老师讲创客道(二十七)

Practical Python基础1(数据类型,运算,比较符号,字符串,列表,函数等)