标题: [原创代码] 【练习-012】实现一行内容分行输出 [打印本页]
作者: sxw 时间: 2011-10-9 15:40 标题: 【练习-012】实现一行内容分行输出
方法一:- #!/usr/bin/perl
- use strict;
- use warnings;
- $"="";
- my $_='aA1一bB2二cC3三dD4四eE5五fF6六gG7七hH8八iI9九';
- my @lower=/[a-z]/g;
- my @upper=/[A-Z]/g;
- my @num=/[0-9]/g;
- my @hz=/[^a-zA-Z0-9]/g;
- print "@lower\n@upper\n@num\n@hz\n";
复制代码
方法二:- #!/usr/bin/perl
- use strict;
- use warnings;
-
- my $string='aA1一bB2二cC3三dD4四eE5五fF6六gG7七hH8八iI9九';
- my $lower=$string=~tr/a-z/ /cr;
- print "$lower\n";
- my $upper=$string=~tr/A-Z/ /cr;
- print "$upper\n";
- my $digit=$string=~tr/0-9/ /cr;
- print "$digit\n";
- my $hz=$string=~tr/a-zA-Z0-9//d;
- print "$string\n";
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |