[EMAIL PROTECTED] wrote:
>
> Hi all, I have a file with a lot of lines like this:
> ...........
> entered;Medium;Major;This is an example synopsis;This is an example problem 
> description;toto
> standby;Urgent;Minor;This is an example synopsis2;This is an example problem2;toto2
> .........
>
> for each line of the file i want to fill in another file foo.txt like
> this:
>
> PROBTRAC: Continuus Problem Tracking System Submittal Form  #this is
> constant
> !crstatus = entered
> !severity: Medium
> !priority:Major
> !problem_synopsis: This is an example synopsis
> !problem_description: !text
> This is an example problem description.
> And a second line of the example description.
> !end_text
> !submitter:toto
>
> PROBTRAC: Continuus Problem Tracking System Submittal Form  #this is
> constant
> !crstatus = entered
> !severity: Urgent
> !priority:Major
> !problem_synopsis: This is an example synopsis2
> !problem_description: !text
> This is an example problem2
> !end_text
> !submitter:toto2
>

Hi. I think your best bet is to go for Perl's format function. It's not clear
how the multi-line problem description appears in the original data, but
I'll assume that it's simply a single field wrapped at a given margin.

The code below may do as you want. You should be able to do the
required open calls to redirect your input and output.

HTH,

Rob



#perl
use strict;
use warnings;

while ( <DATA> ) {
    chomp;
    my @data = map { s/^\s+//; s/\s+$//; $_ } split /;/;
    reformat ( @data );
}


sub reformat {

format =
PROBTRAC: Continuous Problem Tracking System Submittal Form
!crstatus = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
shift
!severity: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
shift
!priority: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
shift
!problem_synopsis: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
shift
!problem_description: !text
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
my $temp = shift
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
$temp
!end_text
!submitter: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
shift

.

    write;
}

__DATA__
entered;Medium;Major;This is an example synopsis;This is an example problem 
description;toto
standby;Urgent;Minor;This is an example synopsis2;This is an additional example 
problem description of especially extended length to
demonstrate the functioning of the format system's built-in multiple-line formatting 
capabilities as comprehensively as
possible;toto2

output:

PROBTRAC: Continuous Problem Tracking System Submittal Form
!crstatus = entered
!severity: Medium
!priority: Major
!problem_synopsis: This is an example synopsis
!problem_description: !text
This is an example problem description
!end_text
!submitter: toto

PROBTRAC: Continuous Problem Tracking System Submittal Form
!crstatus = standby
!severity: Urgent
!priority: Minor
!problem_synopsis: This is an example synopsis2
!problem_description: !text
This is an additional example problem description of
especially extended length to demonstrate the functioning
of the format system's built-in multiple-line formatting
capabilities as comprehensively as possible
!end_text
!submitter: toto2




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to