如何编写代码用文件中的逗号替换空格

人气:694 发布:2022-09-22 标签: perl

问题描述

36985 arrunav 25871 elarital 48734 depaal 43212 sujan 23467 我的数据是这种形式我需要在perl脚本中用逗号替换空格,而不是如何编写上述数据的代码 我的数据输出应该是arun,36985 arrunav,25871 elarital,48734 depaal,43212 sujan,23467

解决方案

例如,请参阅: SEARCH&替换 [ ^ ]。 例如

  

s = arun 36985;

s =〜s / /,/; print

arun 36985 arrunav 25871 elarital 48734 depaal 43212 sujan 23467 my data is in this form i need to replace space with comma in perl script than how can i write the code for the above data my data out put should be arun,36985 arrunav,25871 elarital,48734 depaal,43212 sujan,23467

解决方案

See, for instance, here: SEARCH & REPLACE[^]. e.g.

s = "arun 36985";

s =~ s/ /,/; print

410