in reply to nested loops to compare 2 files is only looping a limited number of times.

First thing I noticed is that you split file 1 like so:
($username, $firstname, $lastname, $lastlogin, $tokenexpiration) = spl +it(",", $line);
but the data looks like this:
Alan,Bloggs,06/11/2009,11/30/2011
meaning that $username is set to Alan, $firstname is set to Bloggs, etc.

Update: To avoid problems, I'd change your regex checking against the entire line ($line2 =~ /$lastname/ ... ) to something more precise.
my ( $bs, $firstname_line_2, $lastname_line_2 ) = split (/,/,$line2); if ( $lastname eq $lastname_line_2 && $firstname eq $firstname_line_2 +) { ...

Replies are listed 'Best First'.
Re^2: nested loops to compare 2 files is only looping a limited number of times.
by stevemayes (Scribe) on Jun 23, 2009 at 13:22 UTC
    oops, yes, I removed the username and obfuscated the surnames but forgot to remove the variable from the code. sorry.
Re^2: nested loops to compare 2 files is only looping a limited number of times.
by ack (Deacon) on Jun 23, 2009 at 15:25 UTC

    Excellent observations. And the fact that the file pointer doesn't automatically reset to the top of the file on each iteration is something that I periodically get hammered by, too.

    I think I would not have bothered with regexs at all. In the OP's posting, the lines from File 1 are already split and it would be trivial to do the same with File 2. I would think it would be clearer and more straightforward to do both splits and then do a simple logical compare on the name-parts.

    The regex's, of course, will work (especially given some of the other suggestions from responders to the OP's post); but it seems like the logical compares would be more readable and maintainable, IMHO. But that's just my perspective.

    ack Albuquerque, NM