我正在做一个项目,我需要从用户那里获取输入,然后将其切割成单独的字符以供以后使用(将它们向上移动一个字符),但是我无法将输入输入到数组和将其打印出来以检查其是否在其中。目前我的代码是
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $count=0; # this block just creates variables
my $userinput;
print "Input?";
$userinput=<STDIN>; # this block just gets input and creates the array
my @userarray=();
while(<@userarray>) {
@userarray = split('', $userinput); #this block should loop as many times as there are characters in the input while separating the characters
}
print Dumper(@userarray); #this should print the array
如果他们的输入是“房子”,我的输出应该看起来像这样
@userarray[0]= "h"
@userarray[1]= "o"
@userarray[2]= "u"
@userarray[3]= "s"
@userarray[4]= "e"
但是,当我确实在其中输入某些内容时,尽管有严格的警告并且没有返回任何内容,但它只是打印出一个空白屏幕。我哪里做错了?