Re: Text parsing and substitution



maheshpop1@xxxxxxxxx schreef:

change the following sentence

"1:action=commit:user=joe:date=2005-02-02:"
"2:action=checkout:user=mark:date=2005-02-03:"

to something like
" 1. Commits by user Joe on date 2005-02-02 "
" 2. Checkouts by user Joe on date 2005-02-03"


This assumes that the fields are allways in the same order:

#!/usr/bin/perl
use strict;
use warnings;

while ( <DATA> )
{
s{ ^ ([^:]+)
: (action) = ([^:]+)
: (user) = ([^:]+)
: (date) = ([^:]+)
:
}
{$1. \u$3s by $4 \u$5 on $6 $7}x
and print
}

__DATA__
1:action=commit:user=joe:date=2005-02-02:
2:action=checkout:user=mark:date=2005-02-03:

--
Affijn, Ruud

"Gewoon is een tijger."


.



Relevant Pages