use Data::Dumper; use strict; undef $/; open(FILE, "<", "test.txt"); $_ = ; close(FILE); s/\|\n/\,/g;#may need to modify according to newline on your platform, this is fine with win32 s/\|/=>/g; my $hash ; eval("\$hash = {$_}"); print Dumper($hash);