Francesco Guglielmo wrote: > Subject: Who debug me?
Let Perl help you help yourself > That's the problem: > > #!/usr/bin/perl use warnings; # use diagnostics; # for extra help use strict; > my $file = '/home/users/francesco/LISTAORDINATA.txt'; > my $outfile = '/home/users/francesco/Perl/file/usrpasswdemail.txt'; > my $file2 = '/home/users/francesco/Perl/file/peralberto.txt'; > > open (OUT, ">$outfile"); open OUT, '>', $outfile or die "Cannot open $outfile: $!"; > open (INPUTEMAIL, "$file2"); open INPUTEMAIL, '<', $file2 or die "Cannot open $file2: $!"; > # open (INPUTPASS, "$file"); # open INPUTPASS, '<', $file or die "Cannot open $file: $!"; > > while (<INPUTEMAIL>) { > chomp; > > ($usr1,$email) = split (/\s/); If the data is separated by a single space this might work but it is better to use the default split. my ( $usr1, $email ) = split; > open (INPUTPASS, "$file"); > while (<INPUTPASS>) { > chomp; > > ($usr,$pass) = split (/\s/); > > if ($usr == $usr1) {print "$usr $pass $email\n";} > } > } > > Where is my error? > I suppose in the "if"..... > I want to print $usr $pass $email It would be better to use a hash to store one of the files instead of reading it for every lookup. #!/usr/bin/perl use warnings; use strict; my $file = '/home/users/francesco/LISTAORDINATA.txt'; my $file2 = '/home/users/francesco/Perl/file/peralberto.txt'; my $outfile = '/home/users/francesco/Perl/file/usrpasswdemail.txt'; my %users; open INPUTPASS, '<', $file or die "Cannot open $file: $!"; while ( <INPUTPASS> ) { chomp; my ( $usr, $pass ) = split; $users{ $usr } = $pass; } close INPUTPASS; open OUT, '>', $outfile or die "Cannot open $outfile: $!"; open INPUTEMAIL, '<', $file2 or die "Cannot open $file2: $!"; while (<INPUTEMAIL>) { chomp; my ( $usr1, $email ) = split; if ( exists $users{ $usr1 } ) { print "$usr1 $users{$usr1} $email\n"; } } __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]