I am working file transfers between servers that are logged. These eventually have to be uploaded to a database, so I am preprocessing them to check for errors. Each log file entry represented a transfer and they are of the format:
key1=value1 key2=value2
for a total of 16 fields. Most of the transfers are fine, except when someone transfers a file which has name with a space in it. This messes up my processing because I just call split on space in my perl script. Example:
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
This is just one example where there is a space between "Wallpapers" and "Folder.ico". Is there any way to design a regular expression that could account for that and split all those key-value pairs? If there is no regular expression way to do it, could you suggest any other way for me to handle it?
My objective is replace those spaces with nothing (i.e. remove the space) or an underscore so that when I run the script for loading into the database, it won't have a problem just splitting on single space. I am using perl to do all this by the way.