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

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

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

    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.