http://www.perlmonks.org?node_id=1209053


in reply to Create output from Perl hash

I was about to say that since my %hash is inside the loop you get a new empty hash on each iteration, but on closer look it seems you don't even need the hash in the first place. Just check if $line =~ /MSISDN=(.*);/, if true, then $MSISDN is $1 (you don't even have to remove the leading whitespace). But then again your expected output contains a lot of data that is not in your input, so it's very unclear how you are supposed to obtain it.