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:
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: