我曾经知道如何做到这一点。我只想从一个更大的字符串中提取一个子字符串并将其分配给标量。所以这是我破解的 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";
...我得到的输出是这个...
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.
...我希望输出是...
thing4 is thing4
我在这里做错了什么?