Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: comparing file contents

by GrandFather (Sage)
on Nov 15, 2011 at 21:49 UTC ( #938259=note: print w/replies, xml ) Need Help??

in reply to comparing file contents

Show us what you have tried. If you haven't tried anything tell what you have read. If you haven't read anything then do so! Read anything that looks relevant in Tutorials for a start, then come back to us with evidence that you have tried something and we will help with specific problems you may have.

True laziness is hard work

Replies are listed 'Best First'.
Re^2: comparing file contents
by kumaar1986 (Initiate) on Nov 15, 2011 at 21:57 UTC

    I have read that i can use hash to store the text files and can use compare function to check the file contents. use::compare checks files on the whole and does not perform word by word comparison

      So show us some code you have tried and tell us what isn't working for you. A very small amount of sample data, actual output and expected output will help a lot too.

      True laziness is hard work

        I have two files namely ICD-Codes-text which is tab format and other file named female.txt which has been split word by word . i need to compare the contents of female1.txt to ICD-codes file 0th array values. If there is a match then the matched value in female1.txt should be replaced with ICD-code files corresponding 1st array value. I am a beginner in PERL. I tried to write some code but i do not know where am going wrong or its completely wrong. Help me with this please

        #!/usr/bin/perl print "reading 'ansvarig_vardenhet_utf8.txt'\n"; open(WIN, "icd-10-codes.txt"); while($line = <WIN>) { @columns = split(/\t/, $line); #print "$columns[1]"; foreach my $value (@columns) { #print "$value\n" } } close(WIN); print "reading 'ansvarig_vardenhet_utf8.txt'\n"; open(IN, "female1.txt"); while($line = <IN>) { %col = split(/ /, $line); #print "$columns[1]\n"; foreach my $val (%col) { if($val == $columns[0]){ $val =~ s/$val/$columns[1]/g; print IN ">>$val\n"; } } } close(IN);

        file samples z988 Z98.8 - Andra specificerade postoperativa tillstånd z99 Z99 - Beroende av maskinella och andra hjälpmedel som ej klassificeras annorstädes z990 Z99.0 - Beroende av aspirationshjälpmedel z991 Z99.1 - Beroende av respirator z992 Z99.2 - Beroende av njurdialys z993 Z99.3 - Beroende av rullstol z998 Z99.8 - Beroende av annan specificerad utrustning och andra specificerade hjälpmedel z999 Z99.9 - Beroende av icke specificerade maskinella och andra hjälpmedel


        patient has been admitted to the hospital for having infection on the recently operated right leg. w0609 w0609 w0609 w0609 w0609 w0609

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://938259]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2018-06-22 21:20 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.