The way to get started with something like this is to write an algorithm for solving the problem in plain English and then try to break the problem into chunks that you can tackle one by one.
In this case, your first chunk to solve would be how to read all the data from the master file into a format that allows you to compare each entry from the other files with the master file. What you want for this is a Hash of Arrays like so:
my %master = (
Alex => [ [3,44], [124,175] ],
Barry => [ [2,44] ],
# more data here #
);
Here, I associate every name with a list of ranges stored as references to arrays. Each range in turn is also a reference to an Array of two elements, the start and end of the range. Of course you could also store the range as a string. wouldn't really make much of a difference in this case.
Now you can access data for a person by name and iterate over all their ranges like so:
my $some_name = 'Alex';
foreach my $range ( @{$master{$some_name}} ){
my ($start, $end) = @$range;
print "$start, $end\n";
}
What you need to figure out now is how to read your master into the %master hash and how to get $some_name and how to compare the ranges. Have a go at that and let us know if you run into problems.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.