我正在使用我在网上找到的这段代码来读取我的 Perl 脚本中的属性文件:
open (CONFIG, "myfile.properties");
while (CONFIG){
  chomp;     #no new line
  s/#.*//;   #no comments
  s/^\s+//;  #no leading white space
  s/\s+$//;  #no trailing white space
  next unless length;
  my ($var, $value) = split (/\s* = \s*/, $_, 2);
  $$var = $value;
}
是否也可以在此 while 循环中写入文本文件?假设文本文件如下所示:
#Some comments
a_variale = 5
a_path    = /home/user/path
write_to_this_variable = ""
我怎样才能在里面放一些文字write_to_this_variable?