Following reworking your code to clean up warnings I get the following output:

0002,Nunki 2 2,6366,59%,0.59,3755.94,Honor,-23,-19 0005,Nunki 2 5,2615,24%,0.24,627.6,Bananiel,-44,-47 0010,Sagittarius 2 5,3414,75%,0.75,2560.5,Iridium,0,-45 0013,Rigel 2 1,6870,30%,0.3,2061,Black_Dragon,-44,95 0014,Rigel 2 2,5000,50%,0.5,2500,Black_Dragon,-35,102 0015,Rigel 2 3,2854,51%,0.51,1455.54,Bananiel,-30,96 0018,Rigel 2 6,4160,59%,0.59,2454.4,Khouri,-49,75 0019,Rigel 2 7,5801,18%,0.18,1044.18,ThrevenGuard,-69,103 0023,Fornacis 2 4,5483,52%,0.52,2851.16,unoccupied
use warnings; use strict; use strict; use warnings; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); my $file2 = <<DATA; 0001,Nunki 2 1,5847,71%,0.71,4151.37,ThrevenGuard,-18,-26 0003,Nunki 2 3,5000,50%,0.5,2500,Honor,-21,-13 0004,Nunki 2 4,4692,39%,0.39,1829.88,Honor,-40,-17 0005,Nunki 2 5,2615,24%,0.24,627.6,Bananiel,-44,-47 0006,Sagittarius 2 1,5000,50%,0.5,2500,Riley Prime,20,-30 0007,Sagittarius 2 2,4731,38%,0.38,1797.78,Bananiel,11,-25 0008,Sagittarius 2 3,6949,18%,0.18,1250.82,Litex,16,-44 0009,Sagittarius 2 4,3004,52%,0.52,1562.08,Bananiel,4,-21 0010,Sagittarius 2 5,3414,75%,0.75,2560.5,5r22,0,-45 0011,Sagittarius 2 6,6146,29%,0.29,1782.34,Bananiel,4,-11 0012,Sagittarius 2 7,6564,61%,0.61,4004.04,dJ,44,-32 0013,Rigel 2 1,6870,30%,0.3,2061,Black_Dragon,-44,95 0014,Rigel 2 2,5000,50%,0.5,2500,Black_Dragon,-35,102 0015,Rigel 2 3,2854,51%,0.51,1455.54,unoccupied 0016,Rigel 2 4,6247,28%,0.28,1749.16,DaSnake,-56,105 0018,Rigel 2 6,4160,59%,0.59,2454.4,Khouri,-49,75 0019,Rigel 2 7,5801,18%,0.18,1044.18,Honor,-69,103 0020,Fornacis 2 1,2409,56%,0.56,1349.04,Mariska,25,51 0021,Fornacis 2 2,5000,50%,0.5,2500,Bananiel,32,44 0022,Fornacis 2 3,6998,32%,0.32,2239.36,Riley Prime,23,35 0023,Fornacis 2 4,5483,52%,0.52,2851.16,Riley Prime,33,33 0024,Fornacis 2 5,5999,63%,0.63,3779.37,Perkins,26,67 0025,Fornacis 2 6,3038,38%,0.38,1154.44,Riley Prime,10,29 DATA my $file1 = <<DATA; 0001,Nunki 2 1,5847,71%,0.71,4151.37,ThrevenGuard,-18,-26 0002,Nunki 2 2,6366,59%,0.59,3755.94,Honor,-23,-19 0003,Nunki 2 3,5000,50%,0.5,2500,Honor,-21,-13 0004,Nunki 2 4,4692,39%,0.39,1829.88,Honor,-40,-17 0006,Sagittarius 2 1,5000,50%,0.5,2500,Riley Prime,20,-30 0007,Sagittarius 2 2,4731,38%,0.38,1797.78,Bananiel,11,-25 0008,Sagittarius 2 3,6949,18%,0.18,1250.82,Litex,16,-44 0009,Sagittarius 2 4,3004,52%,0.52,1562.08,Bananiel,4,-21 0010,Sagittarius 2 5,3414,75%,0.75,2560.5,Iridium,0,-45 0011,Sagittarius 2 6,6146,29%,0.29,1782.34,Bananiel,4,-11 0012,Sagittarius 2 7,6564,61%,0.61,4004.04,dJ,44,-32 0015,Rigel 2 3,2854,51%,0.51,1455.54,Bananiel,-30,96 0016,Rigel 2 4,6247,28%,0.28,1749.16,DaSnake,-56,105 0019,Rigel 2 7,5801,18%,0.18,1044.18,ThrevenGuard,-69,103 0020,Fornacis 2 1,2409,56%,0.56,1349.04,Mariska,25,51 0021,Fornacis 2 2,5000,50%,0.5,2500,Bananiel,32,44 0022,Fornacis 2 3,6998,32%,0.32,2239.36,Riley Prime,23,35 0023,Fornacis 2 4,5483,52%,0.52,2851.16,unoccupied 0024,Fornacis 2 5,5999,63%,0.63,3779.37,Perkins,26,67 0025,Fornacis 2 6,3038,38%,0.38,1154.44,Riley Prime,10,29 DATA #create data files open outFile, "> file1.txt"; print outFile $file1; close outFile; open outFile, "> file2.txt"; print outFile $file2; close outFile; #OP's code print "Cache-Control: max-age=30\n"; my %final; my %compare1; my %compare2; my $maxid = "2000"; open(DAT,"file1.txt"); my @data = <DAT>; close(DAT); for(my $i = 0; $i < scalar(@data); $i++) { # dump file data into ha +shed array my $id = substr($data[$i], 0, 4); # get current planet id $compare1{$id} = $data[$i]; delete $data[$i]; } @data = (); open(DAT,"file2.txt"); @data = <DAT>; close(DAT); for(my $i = 0; $i < scalar(@data); $i++) { # dump file data into ha +shed array my $id = substr($data[$i], 0, 4); # get current planet id $compare2{$id} = $data[$i]; delete $data[$i]; } @data = (); open(DAT,">parsed-all.txt"); # open appropriate parsed file and cle +ar it close(DAT); for(my $i = 1; $i <= $maxid; $i++) { my $currid = changeID($i); next if ! defined $compare1{$currid} and ! defined $compare2{$curr +id}; next if defined $compare1{$currid} and defined $compare2{$currid} and $compare1{$currid} eq $compare2{$currid}; open(DAT,">>parsed-all.txt"); if (defined $compare1{$currid}) {print DAT $compare1{$currid};} else {print DAT $compare2{$currid};} close(DAT); delete $compare1{$currid}; delete $compare2{$currid}; } exit; sub changeID { return sprintf "%04d", $_[0]; }

Perl is Huffman encoded by design.

In reply to Re: Comparing lines of multiple files by GrandFather
in thread Comparing lines of multiple files by oomwrtu

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.