#!/usr/bin/perl #use strict; use warnings; use Text::CSV; my %datei = ( shop => 'xt_customers.csv', wawi => 'xt_customers.txt', neu => 'all_customers.csv', ); sub load_cache { my $file = shift; my %cache; my $csv = Text::CSV->new ( { binary => 1 , sep_char => ";" } ) or die "File not found: ".Text::CSV->error_diag (); my $row; open my $fh, "<:encoding(iso-8859-1)", $file or die $file." $!"; while ( $row = $csv->getline ( $fh ) and ref $row eq 'ARRAY') { $cache{'ID'}{@$row[0]} = $cache{'Mail'}{@$row[6]} = $row; } return \%cache; } my $cache_shop = load_cache( $datei{'shop'} ); my $cache_wawi = load_cache( $datei{'wawi'} ); my $cache_neu = %{ load_cache( $datei{'shop'} ) }{'ID'}; for my $ID ( keys %{ $cache_wawi{'ID'} }) { $cache_neu{ $ID } = $cache_wawi{'ID'}{ $ID } if not exists $cache_shop{'ID'}{ $ID } and not exists $cache_shop{'Mail'}{ $cache_wawi{'ID'}{$ID}[6] }; } for my $row ( values %$cache_neu ) { print join(';', @$row[0..17])