substr() as subroutine argument

my @list = ("field1       field2 field3");

sub stripws($) {
     $_[0] =~ s/\s//g;
     return $_[0];
}
 
foreach (@list) {
    my $x = stripws(substr($_,10,10));
    print "$x\n";
}

Jim expected $x to be equal to 'field2', but instead $x is 'field2fiel'.

Next