I am not quite sure what you intend. An example output would have been helpful.

One approach is to construct a hash of FILE1 based upon the NAME.
Read FILE2 and see if any records update JOB for a NAME in FILE1.
I am not sure if this is the intent?

Changing all occurrences of MD -> Doctor without reading FILE2 would be easier, but then what is the point of FILE2?.

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Data::Dump qw /pp/; $|=1; #turn off buffering to stdout use Inline::Files; use constant {JOB =>0, CITY=>1, STATE=>2}; my %db; <FILE1>; #skip first line of file while (<FILE1>) { next if /^\s*$/; #skip blank lines in file chomp; my ($Name, $Job, $City, $State) = split /\s*,\s*/,$_; $db{$Name}=[$Job, $City, $State]; } <FILE2>; #skip first line of file while (<FILE2>) { next if /^\s*$/; #skip blank lines in file chomp; my ($Name, $Job, $City, $State) = split /\s*,\s*/,$_; if (exists $db{$Name}) { my $current_job = @{$db{$Name}}[JOB]; if ($current_job ne $Job) { print "$Name\'s job changed $current_job->$Job\n"; @{$db{$Name}}[JOB] = $Job; } } } pp \%db; =Prints Jim's job changed MD->Doctor Julie's job changed MD->Doctor George's job changed MD->Doctor Uma's job changed MD->Doctor Pete's job changed MD->Doctor { Bob => ["Nurse", "Pinole", "CA"], George => ["Doctor", "Pinole", "CA"], Jim => ["Doctor", "Pinole", "CA"], Julie => ["Doctor", "San Pablo", "CA"], Kate => ["Nurse", "Oakland", "CA"], Pete => ["Doctor", "San Pablo", "CA"], Sherry => ["Nurse", "Pinole", "CA"], Tara => ["Nurse", "San Pablo", "CA"], Tim => ["Nurse", "Pinole", "CA"], Uma => ["Doctor", "San Pablo", "CA"], } =cut __FILE1__ Name, Job, City, State Jim, MD, Pinole, CA Tara, Nurse, San Pablo, CA Julie, MD, San Pablo, CA Sherry, Nurse, Pinole, CA George, MD, Pinole, CA Tim, Nurse, Pinole, CA Bob, Nurse, Pinole, CA Uma, MD, San Pablo, CA Kate, Nurse, Oakland, CA Pete, MD, San Pablo, CA __FILE2__ Name, Job, City, State Jim, Doctor, Pinole, CA Tara, Nurse, San Pablo, CA Julie, Doctor, San Pablo, CA Sherry, Nurse, Pinole, CA Jan, Doctor, San Pablo, CA George, Doctor, Pinole, CA Tim, Nurse, Richmond, CA Bob, Nurse, Pinole, CA Uma, Doctor, San Pablo, CA Kate, Nurse, Oakland, CA Paul, Doctor, Oakland, CA Ruth, Nurse, Richmond, CA Joe, Nurse, Oakland, CA Nick, Nurse, Pinole, CA Pete, Doctor, San Pablo, CA

In reply to Re: Arrary issues by Marshall
in thread Arrary issues by deadlift

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.