use strict; use warnings; my $string = q(*IF *VALUE ManagedSystem.Product *EQ NT *AND *VALUE ManagedSystem.Status *EQ '*OFFLINE'); my %dict = ( 'ManagedSystem' => { 'Product' => 'Product Code', 'Status' => 'Status', }, '*IF' => 'If', '*VALUE' => 'the value of', '*EQ' => 'is equal to', '*AND' => 'and', q('*OFFLINE') => q('OFFLINE'), ); my @parts = split /\s+/, $string; foreach my $p ( @parts ) { if ( $p =~ m/\./ ) { my ( $attr_grp, $attr ) = split /\./, $p; $p = $dict{ $attr_grp }{ $attr } if exists $dict{ $attr_grp }{ $attr }; } else { $p = $dict{ $p } if exists $dict{ $p }; } print $p . ' '; } print "\n";