#!/usr/bin/perl
use strict;
use warnings;
my $input = "DATE=20130411140806.384553 HOST=somehost PROG=someserver NL.EVNT=FTP_INFO START=20130411140806.384109 USER=someuser FILE=/extended_path/Wallpapers Folder.ico BUFFER=98720 BLOCK=262144 NBYTES=0 VOLUME=/ STREAMS=2 STRIPES=1 DEST=[0.0.0.0] TYPE=STOR CODE=226";
$input =~ s/[ ](?!\S+=)/_/g;
print "\nReplacing:\n$input\n";
$input = "DATE=20130411140806.384553 HOST=somehost PROG=someserver NL.EVNT=FTP_INFO START=20130411140806.384109 USER=someuser FILE=/extended_path/Wallpapers Folder.ico BUFFER=98720 BLOCK=262144 NBYTES=0 VOLUME=/ STREAMS=2 STRIPES=1 DEST=[0.0.0.0] TYPE=STOR CODE=226";
while($input =~ m/(\S+)=((?:\S|[ ](?!\S+=))+)/g)
{
print "Match found:\n Key: $1\n Value: $2\n"; }
IyEvdXNyL2Jpbi9wZXJsCgp1c2Ugc3RyaWN0Owp1c2Ugd2FybmluZ3M7CgpteSAkaW5wdXQgPSAiREFURT0yMDEzMDQxMTE0MDgwNi4zODQ1NTMgSE9TVD1zb21laG9zdCBQUk9HPXNvbWVzZXJ2ZXIgTkwuRVZOVD1GVFBfSU5GTyBTVEFSVD0yMDEzMDQxMTE0MDgwNi4zODQxMDkgVVNFUj1zb21ldXNlciBGSUxFPS9leHRlbmRlZF9wYXRoL1dhbGxwYXBlcnMgRm9sZGVyLmljbyBCVUZGRVI9OTg3MjAgQkxPQ0s9MjYyMTQ0IE5CWVRFUz0wIFZPTFVNRT0vIFNUUkVBTVM9MiBTVFJJUEVTPTEgREVTVD1bMC4wLjAuMF0gVFlQRT1TVE9SIENPREU9MjI2IjsKCnByaW50ICIkaW5wdXRcbiI7CiRpbnB1dCA9fiBzL1sgXSg/IVxTKz0pL18vZzsKcHJpbnQgIlxuUmVwbGFjaW5nOlxuJGlucHV0XG4iOwoKCiRpbnB1dCA9ICJEQVRFPTIwMTMwNDExMTQwODA2LjM4NDU1MyBIT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