!/usr/bin/perl use strict; use warnings; my @tags = qw( 8 9 35 50 97 57 34 49 56 43 52 200 207 40 55 11 167 54 59 44 21 38 60 1 10); my $reg_ex = join( '|', @tags ); open(FH, "test.log")||die("Unable to open log file: $! \n"); while() { printf("Working on String : $_ \n"); if( /\[(.*)\]/) { printf("New String: <$1> \n"); my @vals = split(/(8=|9=)/, $1); foreach my $l (@vals) { printf("$l\n"); } } }