用{}修饰变量名,可以防止 _ 被解释为变量名的一部分。

sub test {
    my $head = "abc";
    my $tail = "def";

    my $full = "${head}_${tail}";
    print $full, "\n";
}

直接写成下面这样,在strict模式下是无法通过的。

my $full = "$head_$tail";

相关文章:

  • 2021-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-02-11
  • 2022-01-15
  • 2022-01-04
  • 2021-10-16
  • 2022-02-16
猜你喜欢
  • 2022-01-05
  • 2022-02-28
  • 2022-03-03
  • 2022-12-23
  • 2021-06-04
  • 2021-09-25
  • 2021-12-03
相关资源
相似解决方案