Re: Text parsing and substitution
- From: <corff@xxxxxxxxxxxxxxxxxx>
- Date: 19 May 2006 10:57:24 GMT
maheshpop1@xxxxxxxxx wrote:
: Hi guys,
: I am doing this module where I am gonna 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"
Check whether all your data follow the same pattern and obey the same
constraints. Apparently you'r doing something in fields here, so:
$rawtext="1:action=commit:user=joe:date=2005-02-02:";
($no,$rawaction,$rawuser,$rawdate)=split(/:/,$rawtext);
# Treat each raw element like this:
($nil,$user)=split(/=/,$rawuser);
# Keep a hash for full user names (and for actions as well):
%users(
"joe" => "Joe",
"dan" => "Daniel",
...
);
# Build your phrase in free English, like:
print "On $date, user $users{$user} $actions{$action}...";
Hth,
Oliver.
--
Dr. Oliver Corff e-mail: corff@xxxxxxxxxxxxxxxxxx
.
- References:
- Text parsing and substitution
- From: maheshpop1
- Text parsing and substitution
- Prev by Date: Re: Adding to a number in replace
- Next by Date: Re: Search and replace with confirmation
- Previous by thread: Text parsing and substitution
- Next by thread: Re: Text parsing and substitution
- Index(es):
Relevant Pages
|