Long list of remarks follows...

for my $arg (@ARGV) { #$script=$ARGV[0]; #$stanza=$ARGV[1]; $metricsfile=$ARGV[0]; $resultfile=$ARGV[1]; }

The for loop does nothing, remove it!

use strict; # always! use warnings; # always!
### Assigning the argument file to in_file #### $in_file = $metricsfile;

No need for cmts that do not improve readability, and even degrade it. Well written code should be self explanatory.

Why assigning to yet another scalar and not using $metricsfile directly?

open (IN, "<$in_file") or die "Can't open $in_file: $!";

For the n-th time, n being a huge integer: you'd better use the 3-args form of open and lexical filehandles.

### A while condition to read all the lines in a file and place in an +array#### #my $linenum=1; while(@linesFromMetrics=<IN>){ # opening while loop

NO! you either want

my @lines=<IN>; # or while (my $line=<IN>) { # ...
#print "Reading metrics file \n"; #print $linenum++;

You may be interested in $. - read more about in perldoc perlvar.

### Assigning the argument file to in_file #### $input_file = $resultfile;

Your comment is not consistent with your code in two ways: missing sigil and wrong variable name. One more reason not to have useless comments: if you change, say, a variable name, then you'll have to change the comment as well.

Well, that's kinda too much. I'll suggest you another way round - this assumes your files are reasonably sized:

#!/usr/bin/perl use strict; use warnings; die "Usage: $0 <file1> <file2>\n" unless @ARGV==2; my %orig=map {$_ => 1} do { open my $fh, '<', $ARGV[0] or die $!; <$fh>; }; open my $fh, '<', $ARGV[1] or die $!; $orig{$_} and print while <$fh>; __END__

This is intendedly minimal: expand and adapt to your needs!


In reply to Re: compare records in two csv files by blazar
in thread compare records in two csv files by boddeti

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.