
MrPJ
User
Feb 17, 2005, 11:34 AM
Post #4 of 4
(1706 views)
|
|
Re: [davorg] look simple, finding tough to split
[In reply to]
|
Can't Post
|
|
A quick attempt...
my $line = 'first=Andrew last=chapell time="2005:02:14 21:59:59" info="Successfully authenticated" userid=andrew src=45231 dst=3213'; my $last = 0; my %temp = (); my $past = ''; while ($line =~ /((\w+)=)/g) { my $match_len = length $1; my $start_pos = $last; $last = pos $line; $temp{$past} = substr($line, $start_pos, $last - $start_pos - $match_len) if ($past); $past = $2; } $temp{$past} = substr($line, $last); print "Content-type: text/plain\n\n"; print map { "$_ => $temp{$_}\n" } sort keys %temp;
(This post was edited by MrPJ on Feb 17, 2005, 11:35 AM)
|