Note that you can open a file with CRLF line endings for reading with the :crlf IO layer. chomp will then remove both line ending characters.
johngg@shiraz:~/perl/Monks$ perl -Mstrict -Mwarnings -MData::Dumper -E
+ '
my $fileStr = qq{val1=key1\r\nval2=key2\r\nval3=key3\r\n};
open my $inFH, q{<:crlf}, \ $fileStr or die $!;
my %hash;
while ( <$inFH> )
{
chomp;
my( $v, $k ) = split m{=};
$hash{ $k } = $v;
}
close $inFH or die $!;
print Data::Dumper
->new( [ \ %hash ], [ qw{ *hash } ] )
->Sortkeys( 1 )
->Dumpxs();'
%hash = (
'key1' => 'val1',
'key2' => 'val2',
'key3' => 'val3'
);
I hope this is helpful.