您只需将其替换为substr
。
use 5.12;
my $foo = '123456789';
substr $foo, 4, 2, q{};
say $foo; # prints 1234789
您可以使用substr()
作为左值
my $str = "123456789";
substr($str, 4, 2) = "";
print $str;
输出
1234789
您可以使用substr功能:
#!/usr/bin/perl
use strict;
use warnings;
my $string = "123456789";
substr($string, 4, 2, '');
print $string, "\n";
输出:
1234789