http://www.perlmonks.org?node_id=1208787


in reply to Comparision Utility PERL

Kindly guide

Since it's trivial:

for my $fieldnum (0 .. $#fields) { if ( exists $hash{ $fields[$fieldnum] } ) { print $fh "$row\n"; next; } }

Untested, since the original code provided is not an SSCCE.

Update: Note that vighneshmufc has altered the parent post to change the spec. This and the rest of the subthread may make less sense than originally.

Replies are listed 'Best First'.
Re^2: Comparision Utility PERL
by vighneshmufc (Acolyte) on Feb 09, 2018 at 09:08 UTC
    UPDATE
    i didnt understand this what did you do ?
    i need to run this file as perl filename.pl file1 file2 file3 Col2 col3
    i am very new to this . Also i reduced the sample.

      I have added a loop so that your comparison of one field against the row becomes a comparison of all fields against the row. That is what you wanted, no?

      Have a look at each statement in that block one by one. If you don't understand anything there, try to find it in the documentation with perldoc. If you still don't understanding it you can say so here, specifying where you looked and how the documentation you read did not make it clear. You may also peruse the Tutorials here for further guidance.

      Happy learning!

        ok ignore the file3 it was basically for just saving the result to a new file. where can i get the syntax for passing arrays as a command line argument?
        i need to run this file as perl filename.pl file1 file2 file3 Col2 col3
        i am very new to this . Also i reduced the sample.
        i am not quite able to grasp what you meant because i need to use command line arguments