I have a data like this:
Re: Building A
Month
kWh
1
100
2
110
3
105
Re: Building B
Month
kWh
1
200
2
210
3
205
I would like to convert it to multiple text files one for each building. My plan is to:
- extract the values between the building delimiter line
- convert the lines into a table
For task (1) I tried to use the flip-flop operator like this:
while( <DATA> ) {
next unless /^Re: Building A/ .. /^Re: Building B/;
my $line = $_;
print $line;
}
But it does not work because the above will show only the data for building A. The data is for multiple buildings (about 50 of them) so that I need to do this somewhat recursively. I have not started to do task (2).
Any help will be appreciated.
I would do something like this:
A.txt:
B.txt: