Board logo

标题: [原创代码] 【练习-012】实现一行内容分行输出 [打印本页]

作者: sxw    时间: 2011-10-9 15:40     标题: 【练习-012】实现一行内容分行输出

方法一:
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. $"="";
  5. my $_='aA1一bB2二cC3三dD4四eE5五fF6六gG7七hH8八iI9九';
  6. my @lower=/[a-z]/g;
  7. my @upper=/[A-Z]/g;
  8. my @num=/[0-9]/g;
  9. my @hz=/[^a-zA-Z0-9]/g;
  10. print "@lower\n@upper\n@num\n@hz\n";
复制代码
方法二:
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. my $string='aA1一bB2二cC3三dD4四eE5五fF6六gG7七hH8八iI9九';
  5. my $lower=$string=~tr/a-z/ /cr;
  6. print "$lower\n";
  7. my $upper=$string=~tr/A-Z/ /cr;
  8. print "$upper\n";
  9. my $digit=$string=~tr/0-9/ /cr;
  10. print "$digit\n";
  11. my $hz=$string=~tr/a-zA-Z0-9//d;
  12. print "$string\n";
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2