perl小程序

#!/usr/bin/perl $count=0; while($count < 100){ print "\n\n\n\n"; print "please input password: \n"; $count+=2; #print "$count \n"; $ftp=1; $news=2; $zhaoyun=3; $postfix=4; $oracle=5; $ntp=6; $line=<STDIN>; if($line eq "$ftp\n"){   print "ftp \n";   $a=`cat /etc/passwd |grep ftp | sed -n 1p`;   print $a;}else{   if($line eq "$news\n"){      $a=`cat /etc/passwd |grep news | head -n 1`;      print $a;     print "news \n";}else{     if($line eq "$zhaoyun\n"){      $a=`cat /etc/passwd |grep zhaoyun | head -n 1`;      print $a;       print "zhaoyun \n";}else{       if($line eq "$postfix\n"){         $a=`cat /etc/passwd |grep postfix | head -n 1`;         print $a;         print "postfix \n";}else{         if($line eq "$oracle\n"){          $a=`cat /etc/passwd |grep oracle | head -n 1`;           print $a;           print "oracle \n";             }else{           if($line eq "quit\n"){             exit;}else{             if($line eq "$ntp\n"){               $a=`cat /etc/passwd |grep ntp | head -n 1`;               print $a;               print "ntp \n";}else{               print "password input error! \n";              }             }           }         }       }      }    }    } 实现输入对应的数字,打印相应的内容。 [root@bogon perl]# ./test please input password: 1 ftp ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin please input password: 2 news:x:9:13:news:/etc/news: news please input password: 3 zhaoyun:x:500:501::/home/zhaoyun:/bin/bash zhaoyun please input password: fd password input error! please input password: quit [root@bogon perl]#

相关文章

1. 如何去重 #!/usr/bin/perl use strict; my %hash; while(...
最近写了一个perl脚本,实现的功能是将表格中其中两列的数据...
表的数据字典格式如下:如果手动写MySQL建表语句,确认麻烦,...
巡检类工作经常会出具日报,最近在原有日报的基础上又新增了...
在实际生产环境中,常常需要从后台日志中截取报文,报文的形...
最近写的一个perl程序,通过关键词匹配统计其出现的频率,让...