Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Comparision Utility PERL

by vighneshmufc (Acolyte)
on Feb 09, 2018 at 09:08 UTC ( [id://1208788]=note: print w/replies, xml ) Need Help??


in reply to Re: Comparision Utility PERL
in thread Comparision Utility PERL

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.

Replies are listed 'Best First'.
Re^3: Comparision Utility PERL
by hippo (Bishop) on Feb 09, 2018 at 09:16 UTC

    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

        If you want the user to specify specific column numbers then you can pass that as an array in the range of the for loop instead of using all the columns. eg:

        my @cols = (0, 2); # You would actually get these from @ARGV but it do +esn't matter here # ... for my $fieldnum (@cols) { if ( exists $hash{ $fields[$fieldnum] } ) { print $fh "$row\n"; next; } }

        I'm going to ignore any mention of "file3" since this is the first time you have brought it up. See also How do I change/delete my post? lest your changes make no sense.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1208788]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-03-28 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found