in reply to removing same entries between 2 files

Really, there are a number of different ways to accomplish this task. Perhaps one of the most straight foward methods might be (un-tested):

#!/usr/bin/perl use strict; use warnings; open FILE_1, 'file.1' || die 'ERROR:\t$!\n"; open FILE_2, 'file.2' || die 'ERROR:\t$!\n"; while ( my $line = <FILE_2> ) { my ( $filename, $accounts, @nonrelevant ) = split( /\t/, $line ); next if ( $accounts exists( @{[<FILE>]} ) ); print "$accounts:\t$filename\n"; } close FILE_1; close FILE_2;
This is assuming that 'file 2' is tab separated, the layout of the file is as explained, and that I do not know the names or locations of the files.

Otherwise, this (or something very similar) should search the first file for the account you are working with in the second file, and only print out the account and file name of the accounts that are not within the first file.

Good Luck!

---hA||ta----
print map{$_.' '}grep{/\w+/}@{[reverse(qw{Perl Code})]} or die while ( 'trying' );

Replies are listed 'Best First'.
Re^2: removing same entries between 2 files
by wfsp (Abbot) on Nov 26, 2005 at 19:15 UTC

    This may need some testing!

    The die messages have mismatched quotes.

    You open FILE1 and FILE2 but use FILE.

    And I'm not at all sure what

    next if ( $accounts exists( @{[<FILE>]} ) );
    is all about. It doesn't compile.

    I can see what you're trying to do but it needs a bit more work :-)

      Ouch! Not sure what that was supposed to mean either, I was in a little of a rush and just typed the program into the input form; my apologies. Here is a more 'refined' version of what I meant:

      #!/usr/bin/perl use strict; use warnings; open FILE, 'file.1.dat'; my $hist = {map{ chomp; $_ => 1 } @{[<FILE>]}}; close FILE; open FILE, 'file.2.dat'; while ( my $line = <FILE> ) { chomp( $line ); my ( $file, $account, @other ) = split( /\t/, $line ); next if ( exists( $hist->{$account} ) ); print "$account:\t$file\n"; } close FILE; exit; __END__
      My apologies for the confusion again, and Good Luck!!

      ---hA||ta----
      print map{$_.' '}grep{/\w+/}@{[reverse(qw{Perl Code})]} or die while ( 'trying' );
        Thank you both for your help.
        Can you explain the following lines of code?
        my $hist = {map{ chomp; $_ => 1 } @{[<FILE>]}}; by wazzuteke my %lookup = map {chomp; $_ => undef} <$accnts>; by wfsp
        I understand that in both of these lines of code, you're loading the file into a look up table...but i'm not very clear as to what  map{chomp; $_ => 1} or map {chomp; $_ => undef} is doing specifically as i'm unfamiliar with perl syntax. Thank you!