fork(3) download
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. 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";
  7.  
  8. print "$input\n";
  9. $input =~ s/[ ](?!\S+=)/_/g;
  10. print "\nReplacing:\n$input\n";
  11.  
  12.  
  13. $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";
  14. print "\nMatching:\n";
  15. while($input =~ m/(\S+)=((?:\S|[ ](?!\S+=))+)/g)
  16. {
  17. print "Match found:\n Key: $1\n Value: $2\n";
  18. }
Success #stdin #stdout 0s 3696KB
stdin
Standard input is empty
stdout
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

Replacing:
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

Matching:
Match found:
  Key: DATE
  Value: 20130411140806.384553
Match found:
  Key: HOST
  Value: somehost
Match found:
  Key: PROG
  Value: someserver
Match found:
  Key: NL.EVNT
  Value: FTP_INFO
Match found:
  Key: START
  Value: 20130411140806.384109
Match found:
  Key: USER
  Value: someuser
Match found:
  Key: FILE
  Value: /extended_path/Wallpapers Folder.ico
Match found:
  Key: BUFFER
  Value: 98720
Match found:
  Key: BLOCK
  Value: 262144
Match found:
  Key: NBYTES
  Value: 0
Match found:
  Key: VOLUME
  Value: /
Match found:
  Key: STREAMS
  Value: 2
Match found:
  Key: STRIPES
  Value: 1
Match found:
  Key: DEST
  Value: [0.0.0.0]
Match found:
  Key: TYPE
  Value: STOR
Match found:
  Key: CODE
  Value: 226