0

I am trying to modify a parser for delimited files I already wrote so it works on a delimited file that doesn't contain each set of data on the same line. So for example,

||A||B||C||D||E||F
||G||H|||A||B||C||
D||E||F||G||H|||A

where each data set is separated by 3 pipes instead of 2. Can anyone give me some pointers?

2
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by KevinADC
0

if the file isn't too big this might do what you want:

open(FH,'file.txt');
my $data = do {local $/; <FH>};
my @data = split(/\|\|\|/,$data);
print "$_\n" for @data;
0

thanks for the reply, one more question, after grabbing each data set I need to parse out each data field. This doesn't seem to be working:

while(<FILE>){
        my $data = do {local $/; <FILE>};
        my @data = split(/\|\|\|/,$data);

    }

    my @values = split(/\|\|/,$data);
0
my @data = ();
    my @values = ();
    while(<FILE>){
        my $data = do {local $/; <FILE>};
        @data = split(/\|\|\|/,$data);
 
    }
     
    for (@data) {
       @values = split(/\|\|/);
       #do something with @values
    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.