I've tried every which way (newbie here), but can't seem to come up with a good solution.
here's an example of the raw data:
<tag1>01234567890
<tag2>apple
<tag3>juice
<end>
<tag1>12345678901
<tag2>orange
<tag3>juice
<tag4>ACT
<end>
Here's the desired (pipe-delimited) output needed:
tag1|tag2|tag3|tag4|
01234567890|apple|juice||
12345678901|orange|juice|ACT|
Here's what I've tried for the tag portion, but can't figure out how to hash it.
and here's the data portion, but can't get each delimited record on separate lines:
Is it possible to reformat without splitting into two files?
Any help would be appreciated,
thx!
here's an example of the raw data:
<tag1>01234567890
<tag2>apple
<tag3>juice
<end>
<tag1>12345678901
<tag2>orange
<tag3>juice
<tag4>ACT
<end>
Here's the desired (pipe-delimited) output needed:
tag1|tag2|tag3|tag4|
01234567890|apple|juice||
12345678901|orange|juice|ACT|
Here's what I've tried for the tag portion, but can't figure out how to hash it.
Code:
open FILE, $ARGV[0] || die $!;
@values = <FILE>;
close FILE;
open TAGS, ">tags.txt" || die $!;
foreach my $tag(@values) {
$tag =~ s/\<\%(.*)\%\>.*$/\1/g;
chomp ($tag);
#how can I make this into a hash before printing it out?
print TAGS "$tag\|";
}
close TAGS;
and here's the data portion, but can't get each delimited record on separate lines:
Code:
open FILE, $ARGV[0] || die $!;
@values = <FILE>;
close FILE;
open DATA, ">data.txt" || die $!;
foreach my $data(@values) {
$data=~ s/.*\>(.*)$/\1/g;
chomp ($data);
print DATA "$data\|";
}
close DATA;
Is it possible to reformat without splitting into two files?
Any help would be appreciated,
thx!