my $command="cd /tmp"; print "\$command is $command:\n"; my $newdir=(split /\s+/,"$command")[1]; ---取第2个元素 print "\$newdir is $newdir:\n"; [root@jhoa bin]# perl a1.pl $command is cd /tmp: $newdir is /tmp:
my $command="cd /tmp"; print "\$command is $command:\n"; my $newdir=(split /\s+/,"$command")[1]; ---取第2个元素 print "\$newdir is $newdir:\n"; [root@jhoa bin]# perl a1.pl $command is cd /tmp: $newdir is /tmp: