Its easier to focus on each problem if you name each problem :) ... argument passing is how to do subroutines

readFile( 'Text1', \@array1, \@data1 ); readFile( 'Text1', \@array2, \@data2 ); compareTheseThings( \@array1, \@data1 , \@array2, \@data2 ); sub readFile { my( $filename, $arrayref, $dataref ) = @_; use autodie qw/ open close /; open my($fh), '<', $filename ; ... push @$arrayref, ...; push @$dataref, ...; ... close $fh; return; }

use Data::Dump qw/ dd /; ## this? { my( %RedText, %DerText ); $RedText{'Entry 1'}{D}=1; $RedText{'Entry 1'}{N}=2; $DerText{'Entry 3'}{N}=6; $DerText{'Entry 3'}{""}=7; ## uh oh, something fishy $DerText{'Entry 5'}{D}=4; ## uh oh, duplicates overwrite, no good $DerText{'Entry 5'}{D}=9; dd( \%RedText, \%DerText ); } ## maybe this? { my( %RedText, %DerText ); $RedText{'Entry 1'}{1}='D'; $RedText{'Entry 1'}{2}='N'; $DerText{'Entry 3'}{6}='N'; $DerText{'Entry 3'}{7}=''; $DerText{'Entry 5'}{4}='D'; $DerText{'Entry 5'}{9}='D'; dd( \%RedText, \%DerText ); }
So, if the number values are whats unique for each entry (no duplicates, no repeats), this hash of hashes
"entry_id", "fist_number", "second_letter" $hash{"entry_id"}{"fist_number"} = "second_letter"; $bothfiles{first_file}{"entry_id"}{"fist_number"} = "second_letter";

does this make sense to you?


In reply to Re: Methods to store content (choosing a data structure for comparing entries from two different files , hash) by Anonymous Monk
in thread Methods to store content by annel

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.