perl字符串比较 [英] perl string comparison

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

问题描述



我在第一个文件文件中有一列字符串,另一个文件在每行中包含5个列,我的基本目标是查找第一个文件的每个项目/行是否可用在第2个文件的第3列。

我尝试了以下逻辑。方式可能有点圆,但作为初学者尝试如下。


第一个文件中的列以数据为例

Hi,
I have one column of strings in 1st file file and another file which consists of 5 clumns in each line and my basic objective is to find each item/line of 1st file is available in 3rd column of 2 nd file.
And I tried the following logic. It might be bit round about way but as a beginner am trying as follows.

The column in the 1st file is having data as example

展开 | 选择 | Wrap | 行号

推荐答案

@ lilly07


您能否发布剩下的代码,以便我们了解您的情况到了这一点?这将使我们更好地了解周围。


问候,


Jeff
@lilly07
Can you please post the rest of your code so that we can see how you go to this point? That will give us a better understanding all around.

Regards,

Jeff


如果你使用eq比较字符串它们必须是精确匹配,包括空格,控制字符和任何字母字符的大写/小写。我的猜测是你需要先敲击()第一个文件中的记录,然后再与第二个文件中的记录进行比较,但为什么要让我们猜?发布代码。 ;)
if you compare the strings using "eq" they must be an exact match, including spaces, control chracters, and upper/lower case of any alpha characters. My guess is that you need to chomp() the records in the first file before comparing to records in the second file, but why make us guess? Post the code. ;)


Thx,Kevin我尝试从第一个文件中扼杀数据,但它仍无法正常工作。请找到我的代码如下。它没有抱怨编译错误。即使我没有复制,我再次重新输入。

Thx, Kevin I tried chomping the data from the first file but still it is not working. Please find my code as below. It is not complaining about compilation error. Even though I didn''t copy, I retyped again.

展开 | 选择 | Wrap | 行号


这篇关于perl字符串比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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