use strict;
use warnings;
use diagnostics;
use Data::Dumper;
use Net::Dict;
my $word = $ARGV[0];
my $dict = Net::Dict->new('test.dict.org');
my $result = $dict->define("$word")->[1][1];
# This is where things don't work as intended
# Original line
# $result =~ 's,\n$,
,gsm';
# Fixed version below
$result =~ s,\n,
,gsm;
print $result;