如何从perl split命令中获取一个标量

Red*_*ket 1 perl

我知道如何做到这一点.我只是想从一个更大的字符串中获取一个子字符串并将其分配给标量.所以这是我破解的Perl脚本......

#!/usr/local/bin/perl 
use warnings;
use strict;

my $thing = "thing1 thing2 thing3 thing4 thing5 thing6 thing7 thing8";
my $thing4 = ${@{split (/ /, $thing)}[3]};
print "thing4 is $thing4\n";
Run Code Online (Sandbox Code Playgroud)

...我得到的输出是......

Use of uninitialized value $_ in split at ./perlex.pl line 6.
Can't use string ("0") as an ARRAY ref while "strict refs" in use at ./perlex.pl line 6.
Run Code Online (Sandbox Code Playgroud)

......我希望输出结果......

thing4 is thing4
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?

jwo*_*der 6

你大大过度工作了split.它应该只是:

my $thing4 = (split / /, $_)[3];
Run Code Online (Sandbox Code Playgroud)