Design: my @input = split(/ /,$ARGV[0]); Expand Map: { don't => do not } ... Pattern Map { Do => You => -template => 'Yes I do', Why => -that => { 'Do you' => 'Because I would like to know', 'Go to sleep' => 'You seem tired' }, Hello => -template => ['How are you', 'What is your name', 'Where are you from?' ], }