Perl 正则二

my $command="cd /tmp";
print "$command  is $command:
";
my $newdir=(split /s+/,"$command")[1]; ---取第2个元素
print "$newdir is $newdir:
";


[root@jhoa bin]# perl a1.pl 
$command  is cd /tmp:
$newdir is /tmp:

原文地址:https://www.cnblogs.com/hzcya1995/p/13352024.html