Link to home
Start Free TrialLog in
Avatar of ghev123
ghev123

asked on

Split file using perl and rename output files based on data in file

Hi there,

I have an input file that is a concatenation of multiple files (variable length).
I am trying to write a perl script that will split the concatenated file into the multiple files that it is made up of.

E.g. the input file is as follows

<start>
customer-id="100"
data 1
<end>
<start>
customer-id="200"
data 2
<end>

The text "<start>" and "<end>" always delimit the files within the input file.

So in this case there would be two new files.

I also need to name the output files with the customer-id that is containned in the data.
So the first output file would be called, for example, 100.out and it would contain
<start>
customer-id="100"
data 1
<end>

and similarly for the second and ay subsequent files

Is all of this possible?

Thanks in advance.
SOLUTION
Avatar of holli
holli

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ghev123
ghev123

ASKER

Guys, this is great, many thanks for the answers. Both are very helpful.