怎么算不。线路号码的出现文件中单独的多个单词? [英] How to count no. of occurance with line no. of multiple words individually in a file?

查看:46
本文介绍了怎么算不。线路号码的出现文件中单独的多个单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我是perl的初学者。我正在编写一个打开文件的程序,从用户那里获取他想要在该文件中搜索的单词的输入,然后打印出来,然后在文件中用相应的行号打印每个单词的出现次数。



以下是我写的代码:

Hi,

I am a beginner at perl. I am writing a program to open a file, take input from user for the words he wants to search within that file, print it then print the no of occurance of each word with respective line no.s in the file.


Below is the code written by me:

展开 | 选择 | Wrap | 行号

推荐答案

好吧,因为我对现在几乎完全过时的PERL感到困扰,所以我不记得最好的方法,但是糟糕的方法是将每一行打破成一系列单词并弹出每个单词我想是在子循环中匹配。这也可以很容易地创建一个行号数组。
Well since i haven''t bothered with the now almost completely obsolete PERL in so long i don''t recall the best way but a crappy way would be to break each line into an array of words and pop off each match in sub-loops I guess. It would also make it easy to make an array of line numbers.


展开 | 选择 | Wrap | 行号





感谢您的回复。但它只是接受输入并按顺序打印它们:(。没有其他事情发生...请帮助



问候,

Dipak Kumar Singh
Hi,


Thanks for your reply. But it is only taking the input and printing them sequentially:(. Nothing else is happening... Please help


Regards,
Dipak Kumar Singh


这篇关于怎么算不。线路号码的出现文件中单独的多个单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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