加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl脚本菜单的简单实现

发布时间:2020-12-16 00:42:53 所属栏目:大数据 来源:网络整理
导读:用《Learning Perl》上的一段代码来说明实现: #!/usr/bin/perl?-w ? use?strict; ? foreach( 1 ?..? 10 ){ ? ? print ? "Iteratin?number?$_.nn" ; ? ? print ? "Please?input?the?choice:?last,?redo,?next,?or?none?of?the?above?" ; ? ? chomp(my?$cho

用《Learning Perl》上的一段代码来说明实现:

 
 
  1. #!/usr/bin/perl?-w ?
  2. use?strict; ?
  3. foreach(1?..?10){ ?
  4. ?
  5. print?"Iteratin?number?$_.nn"; ?
  6. ?
  7. print?"Please?input?the?choice:?last,?redo,?next,?or?none?of?the?above?"; ?
  8. ?
  9. chomp(my?$choice=<STDIN>); ?
  10. print?"n"; ?
  11. last?if?$choice=~?/last/i; ?
  12. next?if?$choice=~?/next/i; ?
  13. redo?if?$choice=~?/redo/i; ?
  14. print?"That?wasn't?any?of?the?choices..?onward!nn"; ?
  15. ?
  16. } ?
  17. print?"That's?all,?folks!n";?

我们可以替换last,next,redo为实际需要执行的函数,修改print语句来让这个菜单更漂亮。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读