如何编写代码用文件中的逗号替换空格 [英] how to writea code to replace space with comma in a file

查看:162
本文介绍了如何编写代码用文件中的逗号替换空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


这篇关于如何编写代码用文件中的逗号替换空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆