use Regexp::Common 'RE_profanity'; foreach my $row ( @$rows ) { # $row is a hash reference containing the # data from a single record $row->{post} =~ s/$RE{profanity}/[censored]/g; } use Data::Dumper; die Dumper $rows; __DATA__ $VAR1 = [ { 'locked' => 'no', 'stick' => 'foobar', 'last_update' => '2004-05-17 00:33:55', 'name' => 'post with curses', 'post' => 'some [censored] [censored] words', 'author' => 'values', 'last_updated_by' => 'jack', 'view' => 'other', 'id' => '2' } ];