Perl脚本菜单的简单实现
用《Learning Perl》上的一段代码来说明实现:[*]#!/usr/bin/perl -w
[*]use strict;
[*]foreach(1 .. 10){
[*]
[*]print "Iteratin number $_.\n\n";
[*]
[*]print "Please input the choice: last, redo, next, or none of the above?";
[*]
[*]chomp(my $choice=);
[*]print "\n";
[*]last if $choice=~ /last/i;
[*]next if $choice=~ /next/i;
[*]redo if $choice=~ /redo/i;
[*]print "That wasn't any of the choices.. onward!\n\n";
[*]
[*]}
[*]print "That's all, folks!\n";
我们可以替换last,next,redo为实际需要执行的函数,修改print语句来让这个菜单更漂亮。
页:
[1]