my ( @commands, @matches, $ip ); for my $i ( 0 .. $#temp ) { #process each subset if ( $i == 0 ) { my @temp1 = split /:/, $temp[ 0 ]; #this is the first subset, it contains the IP $ip = $temp1[ 0 ]; $count++; $temp[ 0 ] =~ s/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4 +][0-9]|[01]?[0-9][0-9]?)://; #remove IP from subset } my @arr; if ( $temp[ $i ] =~ /=/ ) { #this subset contains pattern-matching instructions my @temp2 = split /=/, $temp[ $i ]; #split subset into further subsets, first co +ntaining the command, the rest are patterns push @commands, substitute_placeholders( $temp2[ 0 ], \@metachars, \@translations ); #all +splitting is done on this string, revert it back to its original form for my $c ( 1 .. $#temp2 ) { #these are all the patterns push @arr, substitute_placeholders( $temp2[ $c ], \@metachars, \@translations ); + ##undo prior substitutions } push @matches, \@arr; } else { #this subset does not contain pattern matching instructions push @commands, substitute_placeholders( $temp[ $i ], \@metachars, \@translations ); ##und +o prior substitutions push @arr, "no-match-hook"; ##set flag for easy identification later on in the s +cript push @matches, \@arr; } } $$DATA->{ $ip }{ commands } = \@commands; $$DATA->{ $ip }{ matches } = \@matches;