- 论坛徽章:
- 0
|
回复 #1 yang-wei 的帖子
zhuangbility的写法
- #!/usr/bin/perl
- use strict;
- use warnings;
- my $index = shift || 0;
- my $data = "the first file is abc.jpg the second file is cba.jpg the third file is bac.jpg and ";
- print +($data =~ /(\w+\.jpg)/g)[$index],"\n";
复制代码
<lig@other-server:~/chinaunix>$ ./match
abc.jpg
<lig@other-server:~/chinaunix>$ ./match 1
cba.jpg
<lig@other-server:~/chinaunix>$ ./match 2
bac.jpg
<lig@other-server:~/chinaunix>$ ./match -1
bac.jpg
<lig@other-server:~/chinaunix>$ ./match -2
cba.jpg |
|