#!/usr/bin/perl use strict; use warnings; use Text::CSV; # Hier kommen die Suchanweisungen, wie auch immer die angeliefert werden. my %search = ( Source => { pattern => qr(10.*) , match => 1 } , Port => { pattern => qr(22) , match => 1 } , System => { pattern => qr(cose4711) , match => 0 } ); my $csv = Text::CSV->new ( { binary => 1, sep_char => ';' } ) or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $fh, "<:encoding(utf8)", "test.csv" or die "test.csv: $!"; my $header = $csv->getline($fh); READCSV: while ( my $row = $csv->getline($fh) ) { for my $col (0..$#{$header}) { next unless my $comp = $search{$header->[$col]}; my $match = ($row->[$col] =~ $comp->{pattern}) ? 1 : 0; next READCSV unless $match == $comp->{match}; } print "Hit in row $.!\n"; }