Perl:HEX参数处理 [英] Perl : HEX parameter handling

查看:257
本文介绍了Perl:HEX参数处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




请说明如何编写:一个脚本,它读取文件并在文件文本中搜索ABC或FGH等字样,并在它们出现后放入一些变量。该变量是可配置的HEX参数,可以通过配置文件配置,也可以作为命令行参数给出。


谢谢

Hi,

Please tell how to write :A script which reads a file and search for some words like ABC or FGH in the file text and put some variable after their occurance.That variable is configurable HEX parameter which can be configured through config file or can be given as a command line parameter.

Thanks

推荐答案

< RANT>

不,谢谢


如果您真的想要一些帮助,您似乎应该至少在此问题上付出一些努力张贴在这个论坛上。向我们展示一些代码。告诉我们您至少已经考虑过可能的解决方案并且只是遇到了问题。到目前为止,您所做的一切都证明您可以复制和粘贴作业。

< / RANT>
<RANT>
No Thanks

If you really would like some help you should appear to have put at least some effort into the problem before posting on this forum. Show us some code. Show us that you have at least thought about possible solutions and have simply run into a problem. All you''ve done thus far is demonstrated that you can copy and paste a homework assignment.
</RANT>


大家好,

我可以为上述问题编写一些代码。

代码如下:

但我还有2个问题。


1.执行脚本时出现一些空白行,我需要删除这些空白行。并且


2.我需要比较给定文件的两行,比如


BHS | ^〜\& | NVA |

MSH | ^〜\& | NVA |

MSH | ^〜\& | NVB |

EVN | P03 | 20060702 |

PID | | 5360738 |


如果在BHS段之后出现MSH段,则将首次出现的MSH更改为MSD。


代码:


#!/ usr / local / bin / perl -w



#这个经典编程风格的Perl程序改变了

#字符串" headerOld"到headerNew在所有文件中

#在命令行中指定。


@headerOld =('''BHS'',''BTS'',''FTS' ');

@headerNew =(" \ nABSHS"," \ nBBTS"," \ nFFTS");



for(
Hi All ,

I am able to write some code for the above said problem.
The code is given below .
But i still have 2 problems.

1. There is occurance of some blank lines when i execute the script, I need to remove those blank lines. and

2. I need to compare the two lines of a given file ,say

BHS|^~\&|NVA |
MSH|^~\&|NVA |
MSH|^~\&|NVB |
EVN|P03|20060702 |
PID| |5360738 |

If there is occurance of MSH segment after BHS segment then change the first occurance of MSH to MSD.


Code:

#!/usr/local/bin/perl -w


# This Perl program in classic programming style changes
# the string "headerOld" to "headerNew" in all files
# specified on the command line.

@headerOld=(''BHS'',''BTS'',''FTS'');
@headerNew=("\nABHS","\nBBTS","\nFFTS");


for (


i = 0;


这篇关于Perl:HEX参数处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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