#! /usr/bin/perl use warnings; use strict; use Getopt::Long; my ($filterPassword, $filterIp, $file, $file2); my $help = 0; # z.B. program.pl -p password -i 127.0.0.1 -file datei.txt # oder: program.pl -h GetOptions( "password=s" => \$filterPassword, "ip=s" => \$filterIp, "file=s" => \$file, "file2=s" => \$file2, "help" => \$help, ); if ($help) { # &PrintHelp.... exit 1; } # if # vielleicht hier noch ueberpruefen, ob $filterPassword und $filterIp gesetzt sind.... unless (open (LOG, "<", $file)) { die "Error: couldn't open '$file': $!\n"; } # unless my %filteredLines; while () { chomp($_); my ($ip, $pass) = split(/ /, $_); if ($pass eq $filterPassword and $ip eq $filterIp) { $filteredLines{$_} = 1; } # if } # while close (LOG); open(FILE2,"<$file2") or die $!; while(){ chomp $_; my ($ip, $pass) = split(/ /, $_); if ($pass eq $filterPassword and $ip eq $filterIp) { print $_,"\n" if($filteredLines{$_}); } # if } close FILE2;