Evaluating escape sequences in perl

后端 未结 3 1519
暗喜
暗喜 2020-12-12 03:40

I\'m reading strings from a file. Those strings contain escape sequences which I would like to have evaluated before processing them further. So I do:

$t = e         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 03:46

    $string =~ s/\\([rnt'"\\])/"qq|\\$1|"/gee
    

    string eval can solve the problem too, but it brings up a host of security and maintenance issues, like @ in string

提交回复
热议问题