Comparing The Numbers Present In Two Files And Get The Matched [Closed]
2
0
Entering edit mode
13.3 years ago
Cynthia ▴ 190

i need to compare the numbers present in two files.

for example in file1.txt:

human
1 2 3 4 5 6 7 8 9

and in another file2.txt:

human
1 2 3 8 0 7 6

the above two files should be given as input. and the output file will be as:

1 2 3 6 7 8

(i.e. the matching numbers present while comparing the two files) if possible the output must come in another file.

perl homework • 3.0k views
ADD COMMENT
4
Entering edit mode

Hi, you are not doing yourself any good with this. Try to solve this problem yourself. It's a good way to learn to program (ltp! ;) ) A good resource for perl coding is also: http://www.perlmonks.org/ After you finished your basic perl course go to Perl Monks page and click: # Seekers of Perl Wisdom

ADD REPLY
4
Entering edit mode

Hi Payaliya. People on this forum try to help each other learn to do their analyses by themselves by sharing information, programs or how-to knowledge. The forum is not a place to ask people to program things for you. The prerequisite here is that you try for yourself to learn how to do things. If you take time to learn Perl, Python or R, you will become MUCH more capable of advancing your projects efficiently. Good learning!

ADD REPLY
0
Entering edit mode

Payaliya - the 'edit' question is not for you to try and close questions by modifying the title. That does not close the question, that is a function for moderators.

ADD REPLY
7
Entering edit mode
13.3 years ago
Michael 54k

In a terminal type and read:

perldoc perltoc
perldoc perlintro
perldoc perlfunc

Good luck

More links and books as requested:

These a bit old but perl 5 didn't change that much over the years.

ADD COMMENT
0
Entering edit mode

+1 Micheal, could you list, as supplementary reading, other perldoc documents you think are worth reading? I have to get done with my ignorance of Perl :)

ADD REPLY
2
Entering edit mode
13.3 years ago
Thaman ★ 3.3k

Your computation is strickly related with file handling so better go through the documentation. Also keep in mind, knowing what and how about programming is ability to read documentation and interperate it wisely.

So what you need is

OR

perldoc perlopentut

# You can type them in command line/shell

  • Second task about comparing string can be done through numerous way like split,grep

Moreover, trying yourself first is the best way to deal with the problems.

If you want quick solution then go to http://stackoverflow.com/

ADD COMMENT

Login before adding your answer.

Traffic: 2529 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6