in reply to Re^2: Eliminating Duplicate Lines From A CSV File
in thread Eliminating Duplicate Lines From A CSV File

Yes, that was an error. Also, see now that Grandfather's solution was about the same as mine. He used a Hash of Hash, where I used a Hash of Array.
If no recs were found in the last file(s), no array entry was created.

Correct line is,
my @avgs = map $usage{$server}[$_] || 0, 0..$files-1;
instead of
my @avgs = map $usage{$server}[$_] || 0, 0..$#{$usage{$server}}; Update: changed 0..$i-1 to 0..$files-1

Replies are listed 'Best First'.
Re^4: Eliminating Duplicate Lines From A CSV File
by country1 (Acolyte) on Jul 26, 2007 at 17:50 UTC

    Cristoforo,


    One final question. My input CSV files actually have
    two Header lines. The files look like this:


    File A
    Server Performance on Jun 9 2007,,,,
    Server,Avg CPU,P95 CPU,Avg Mem Util,P95 Mem Util
    wsomdavpra03,95.33,98.75,68.68,70.23
    WTEADAPOMS02,35.13,88.15,37.9,57.57


    I would have thought the line of code


    next if $line =~ /^Server/;


    would have eliminated the 1st two header lines.


    I also tried using two "<$fh>;" lines after the open
    statement. These both produced the following output
    in the first line.


    ,0,0,0,0,0,0


    Do you have any idea why this is happening?

Re^4: Eliminating Duplicate Lines From A CSV File
by country1 (Acolyte) on Jul 25, 2007 at 19:22 UTC

    Cristoforo,


    The replaced line is causing a compilation error:


    Global symbol "$i" requires explicit package name
    at test1.pl line 54.


    I verified the line number of the changed line - it
    was line 54.