#!/usr/bin/perl -w use strict; # the various fields my @field = qw/id date time if fw type action service src dst proto rule sport reason/; my $i = 0; my %field = map { ($_, $i++) } @field; # create the filter my %filtre = (@ARGV); my @filtre; while(my ($k, $v) = each %filtre) { # better use a while than a for loop push @filtre, '$data['.$field{$k}."]=~m/$v/i"; } my $filtre = join ' && ', @filtre; # open the file my $file = "fw01.log"; open F, $file || die "Error: $file $!\n"; $\= "\n"; print join"--\t--", @field; while() { my @data = (/"(.*?)"/g); print join"\t",@data if eval $filtre; }